<![CDATA[ Mysterious problem with $c->where() result in processor. - My Forums]]> https://forums.modx.com/thread/?thread=104123 <![CDATA[Mysterious problem with $c->where() result in processor.]]> https://forums.modx.com/thread/104123/mysterious-problem-with-c--where-result-in-processor#dis-post-559952 I've got an interesting problem with where() method smiley
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 smiley

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... smiley
Why can it be, guys?
Any thoughts?

You can ask any additional questions.

MODX 2.6.5-pl
PHP 7.2.1
]]>
bakimenko Jul 25, 2018, 11:35 AM https://forums.modx.com/thread/104123/mysterious-problem-with-c--where-result-in-processor#dis-post-559952
<![CDATA[Re: Mysterious problem with $c->where() result in processor. (Best Answer)]]> https://forums.modx.com/thread/104123/mysterious-problem-with-c--where-result-in-processor#dis-post-559990 It was changed to VARCHAR and no problem anymore smiley]]> bakimenko Jul 25, 2018, 07:10 PM https://forums.modx.com/thread/104123/mysterious-problem-with-c--where-result-in-processor#dis-post-559990