We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    I’m trying to emulate a MySQL statement like this:

    SELECT * FROM my_table WHERE id NOT IN (1,2,3);


    Is there an xPDO equivalent? Or is the best thing to do this:

    $query->where(array('id:!=' => 1));
    $query->where(array('id:!=' => 2));
    $query->where(array('id:!=' => 3));
    


    And an added bonus question... Oracle has a limit of 500 of how many values can be specified in an "IN" condition like this... does MySQL too?

    Thanks!
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: Everett at Jan 13, 2011, 06:46 PM

      I’m trying to emulate a MySQL statement like this:

      SELECT * FROM my_table WHERE id NOT IN (1,2,3);


      Is there an xPDO equivalent?
      $criteria->where('id:NOT IN' => array(1,2,3));


      Quote from: Everett at Jan 13, 2011, 06:46 PM

      And an added bonus question... Oracle has a limit of 500 of how many values can be specified in an "IN" condition like this... does MySQL too?
      No idea tbh, but I am aware of a recent bug with sending a large number of values like this via PDO in general, and well, it’s just a bad practice in general if you have a large set of specific values.
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Thanks... yeah, it’s not the best idea, but I’d rather send a set of values to delete like that rather than issuing umpteen many individual delete statements.