Editor (ajax) - how can we use the query wildcard "%"

Editor (ajax) - how can we use the query wildcard "%"

mdesignmdesign Posts: 72Questions: 17Answers: 0

my problem:
i have different admin groups who can connect to editor. so they can read and edit different datas from the database. after login the admin gets a $_SESSION-Variable, like:

$_SESSION['website'] = '%'; // for the Superadmin
$_SESSION['website'] = 'domain.com'; // Normal Admin

but the % wildcard doesn't work - i don't get datas.

like:
->where('db_table.table_field', '%')
->debug(true)
->process($_POST)
->json();

Answers

  • mdesignmdesign Posts: 72Questions: 17Answers: 0

    Nobody who can help with this. ?

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Just % is actually a noop condition - it would be better to do this:

    $editor = Editor::inst( ... )
      ->fields( ... );
    
    if ($_SESSION['website'] !== '%') {
      $editor->where('db_table.table_field', $_SESSION['website']);
    }
    
    $editor
      ->process($_POST)
      ->json();
    

    Allan

  • mdesignmdesign Posts: 72Questions: 17Answers: 0

    thx allan - that does the job!

This discussion has been closed.