Closed keevitaja closed 7 years ago
You can achieve this doing :
$mapper->where(['a' => 1])->andWhere(['b' => 8, 'c' => 4], 'OR');
Any solution for:
where a = 1 and (where b LIKE "8 %" or where b LIKE "% 8 %")
?
$mapper->where(['a' => 1])->andWhere(['b :like' => '8 %', 'b :like' => '% 8 %'], 'OR');
Are you sure? An array with the same key twice?
Sorry, my bad... You can try this workaround:
$query = $mapper->select()->noQuote()->where(['name' => 1])->andWhere(['email :like' => '8 %', 'email :like' => '% 8 %'], 'OR');
echo($query->toSql()).PHP_EOL;
var_dump($query->getParameters());
SELECT * FROM x WHERE (x.name = ?) AND (x.email LIKE ? OR x.email LIKE ?)
array(3) {
[1] =>
int(1)
[2] =>
string(3) "8 %"
[3] =>
string(5) "% 8 %"
}
Ofc you can restructure your request or do a regex instead etc.
Thank you very much! I used another option: created my own operator.
Hello,
is it possible to group where and orWhere without using raw queries?
where a = 1 and (where b = 8 or where c = 4)