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

    I am trying to use the following code to return the data for a selected group of product id's. It works well using equal and like operators but not IN.

    [[!Rowboat?
       &table=`modx_products`
        &tpl=`gallery-products`
        &where=`{"id:IN":(23,27)}`
       &sortBy=`cat`
    


    What is the correct format for using an array with the IN operator?

    I hope that make sense!

    Thanks

      • 33976 ☆ A M B ☆
      • 571 Posts
      Hi danspeich, and welcome on the MODX forums,

      You might want to check how xPDO handles that (see http://rtfm.modx.com/display/xPDO20/xPDOQuery.where).

      So, albeit i haven't tried, i assume your snippet call should be
         &where=`"id:IN":array(23,27)`
      


      Hope that will help smiley
        • 28215
        • 4,149 Posts
        {"id:IN":[23,27]}
        

        Is actually the proper syntax.
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 33976 ☆ A M B ☆
          • 571 Posts
          Woups, seems like i'm spending too much time coding PHP lipsrsealed
          Sorry for the mislead…
            • 37051
            • 2 Posts
            Thank you for the quick replies.

            I have tried using [ instead of ( with no luck. I have tested the query directly with phpAdmin and it works OK.

               
             [[!Rowboat?
               &table=`modx_products`
                &tpl=`gallery-products`
                &where=`{"id:IN":[23,27]}`
               &sortBy=`cat`
            
            


            Is there anything else I can try, or is it an issue with the way Rowboat deals with the query? I feel there must be an obvious solution, but I have tried every possible syntax variation!

            Thanks again.
              • 8883
              • 59 Posts
              Hi,
              I'm using Rowboat 1.1.0 and have the same problem. I want to pick a few datasets by certain IDs.

              <ul class="no-style list-literatur" id="literatur">
              [[Rowboat?
                 &table=`modx_literatur`
                 &tpl=`tpl-rowboat-literature-complete`
                 &limit=`10`
                 &sortBy=`author,year`
                 &debug=`1`
              &where=`{"RECNO:":[206,226]}`
              ]]
              </ul>


              No results...
              and I didnt find a solution in the rtfm.
                • 8883
                • 59 Posts
                &where=`{"RECNO:=":"206","OR:RECNO:=":"226","OR:RECNO:=":"278" works neither properly
                  • 4172
                  • 5,888 Posts
                  &where=`{"RECNO:":[206,226]}`


                  where is your 'IN' ?

                  &where=`{"RECNO:IN":[206,226]}`


                  if rowboat doesn't do it, you can try bloX

                  [[bloX?
                     &packagename=`yourpackage`
                     &classname=`youclass`
                     &tpls=`row:tpl-rowboat-literature-complete`
                     &limit=`10`
                     &sortBy=`author,year`
                     &debug=`1`
                  &where=`{"RECNO:":[206,226]}`
                  ]]



                  [ed. note: Bruno17 last edited this post 13 years, 11 months ago.]
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 8883
                    • 59 Posts
                    Thank you.
                    Your version doesn't work, too.
                    Is there any instruction/documentation for setting up blox (packagename/classname)?
                      • 4172
                      • 5,888 Posts
                      do you have a xpdo-schema for your table?

                      then you just need to fill your packagename and classname into the blox-snippet-call
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!