We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34109
    • 119 Posts
    Hi,

    I'm building a filter which will search on a column which gets its data from a multiselect TV. Because the JSON in the filter has to be decoded, any duplicate keys are overwritten, so I can't set multiple OR conditions on the same column. My snippet which produces the JSON is:

    $output= '{"category:LIKE":"%||'.$cat.'","OR:category:LIKE":"'.$cat.'||%","OR:category:LIKE":"%||'.$cat.'||%","OR:category:=":"'.$cat.'"}';


    When processed, this ends up in this array:

        [category:LIKE] => %||1
        [OR:category:LIKE] => %||1||%
        [OR:category:=] => 1


    Is there any way to end up with all the criteria in an array or am I going to have to hack the MIGX getlist processor?

    This question has been answered by [email protected]. See the first response.

      Studio Republic
      http://www.studiorepublic.com
      0845 226 3205
      @christodhunter
    • discuss.answer
      • 34109
      • 119 Posts
      Figured it out - use capitals. The query is non case-sensitive but the fromJson function is, so this works fine:

      $output= '{"category:LIKE":"%||'.$cat.'","OR:category:LIKE":"'.$cat.'||%","OR:Category:LIKE":"%||'.$cat.'||%","OR:category:=":"'.$cat.'"}';
        Studio Republic
        http://www.studiorepublic.com
        0845 226 3205
        @christodhunter
        • 4172
        • 5,888 Posts
        you can also try:

        $c->where("CONCAT('||',category,'||') LIKE '%||" . $cat . "||%'", xPDOQuery::SQL_AND); 
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!