private function buildQuery()
{
$parameters = array();
/*
* Start query, as you can see this query is build in the wrong place, because of the
* filter it is a special case wherein we allow the query to be in the actionfile itself
*/
$query = 'SELECT pg.id, pg.name, COUNT(gr.id) AS members_count
FROM profiles_groups AS pg
LEFT OUTER JOIN profiles_groups_rights AS gr ON gr.group_id = pg.id AND
(gr.expires_on IS NULL OR gr.expires_on > NOW())
GROUP BY pg.id
HAVING 1';
// add name
if ($this->filter['name'] !== null) {
$query .= ' AND pg.name LIKE ?';
$parameters[] = '%' . $this->filter['name'] . '%';
}
// query
return array($query, $parameters);
}