Search code examples
phpmysqlosticket

Osticket: how to filter tickets with "OR" constraint


I'm adding some custom functionality to OsTicket (1.10) but I can't figure out how to filter tickets of multiple departments.

What I'm doing is:

$departments = [1, 4, 9]; //these are department IDs
$query = Ticket::objects();
$query->filter(['dept_id' => $departments]);
...

The filter() function in VerySimpleModel (class.orm.php) says in a comment:

// Multiple arrays passes means OR

But I guess this means that I can filter with a OR on different columns, not on a single one, which is what I need. I tried navigating the code but I can't find a solution.


Solution

  • Found it, I simply needed to query like this:

    $query->filter(['dept_id__in' => $departments]);