Hi everyone!
I've got an interesting problem with where() method
There are one processor exdends the modObjectGetListProcessor.
On it's input is an array.
In prepareQueryBeforeCount() function I do where() like this:
foreach ($query as $k => $v){
$this->where[$k.':LIKE'] = "%$v%";
}
$c->where($this->where);
Then I use $c->toSql() for checking query result.
Selects and joins are not so interested for us - there is ok, but results of where() method work - that is interesting and slightly mysterious for me
Lets start.
Input array is like this (print from log):
[$query] => Array
(
[id] => 100
[city] => 200
[name] => 300
[phone] => 400
[mail] => 500
[performer] => 600
)
In this array can be digits or strings - whatever.
Variable $this->where looks like:
[$this->where] => Array
(
[id:LIKE] => %100%
[city:LIKE] => %200%
[name:LIKE] => %300%
[phone:LIKE] => %400%
[mail:LIKE] => %500%
[performer:LIKE] => %600%
)
And after where() method works we've got (part of print from log):
WHERE ( `a`.`id` LIKE 0 AND `a`.`city` LIKE 0 AND `a`.`name` LIKE '%300%' AND `a`.`phone` LIKE 0 AND `a`.`mail` LIKE 0 AND `a`.`performer` LIKE 0 )
Only one of values is not 0. Always. Even if input array contains only one of this elements.
By experimental way I clear that zeroing happens when where() get concatenated values like "%$v%" OR "%".$v."%". But why for 'name' is not the same bechaviour?
Why Lord?
Oh... Sorry...
Why can it be, guys?
Any thoughts?
You can ask any additional questions.
MODX 2.6.5-pl
PHP 7.2.1
[ed. note: bakimenko last edited this post 6 years, 4 months ago.]