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

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

mdesignmdesign Posts: 32Questions: 9Answers: 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: 32Questions: 9Answers: 0

    Nobody who can help with this. ?

  • allanallan Posts: 51,422Questions: 1Answers: 7,754 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: 32Questions: 9Answers: 0

    thx allan - that does the job!

Sign In or Register to comment.