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

    say I have a custom db fields with multiple names in a single field like: "John,Alex,Tom". I want to find or get all fields that have any of names passed to the db with migx special tag. Something like search DB for given names to match.
    For instance this works fine when I pass only one name:

    [[!migxLoopCollection?
    			&packageName=`gallery`
    			&classname=`Gallery`
    			&sortConfig=`[{"sortby":"title","sortdir":"ASC"}]`
    			&where=`{"image_names:LIKE":"%John%","published":"1"}`
    			&tpl=`mGalleryAlbum`
    			]]
    


    But how to pass multiple names in one call? I tried different ways: with commas, spaces, etc. nothing seems to be working. Something like this (also need non case-sensitive as well?):

    &where=`{"image_names:LIKE":"%John% or %Tom%","published":"1"}`
    


    Thank you.

    This question has been answered by just_nico. See the first response.

    • discuss.answer
      • 48532
      • 23 Posts
      Untested, but it should work when you use separate array objects .
      &where=`[
            {"image_names:LIKE":"%John%"},
            {"OR:image_names:LIKE":"%Tom%"},
            {"published":"1"}
      ]`
      


      See also https://docs.modx.com/xpdo/2.x/class-reference/xpdoquery
        • 53390
        • 42 Posts
        Nico,
        thank you very much. This works exactly as I wanted.