revert exists filter and replacing by a generic one

This commit is contained in:
Benoît Burnichon
2015-09-24 15:26:33 +02:00
parent 62ba97146d
commit cdb98a1a4e

View File

@@ -68,7 +68,7 @@ class User_Query implements User_QueryInterface
protected $countries = null;
protected $positions = null;
protected $in_ids = null;
protected $existsSql;
protected $sqlFilters = [];
protected $sql_params = null;
public function __construct(Application $app)
@@ -101,9 +101,9 @@ class User_Query implements User_QueryInterface
return $this;
}
public function existsSql($sql)
public function addSqlFilter($sql, array $params = [])
{
$this->existsSql = $sql;
$this->sqlFilters[] = ['sql' => $sql, 'params' => $params];
return $this;
}
@@ -888,8 +888,11 @@ class User_Query implements User_QueryInterface
if ($this->in_ids) {
$sql .= ' AND (Users.id = ' . implode(' OR Users.id = ', $this->in_ids) . ')';
}
if ($this->existsSql) {
$sql .= sprintf(' AND EXISTS(%s)', $this->existsSql);
if ($this->sqlFilters) {
foreach ($this->sqlFilters as $sqlFilter) {
$sql .= ' AND (' . $sqlFilter['sql'] . ')';
$this->sql_params = array_merge($this->sql_params, $sqlFilter['params']);
}
}
if ($this->have_rights) {