Zend Framework – Zend_Db In Clause

I really thought it was hard to implement the IN clause in Zend Db Select, but after a few research, it was very easy just like the other clause in the WHERE clause.

All you need is an array then pass it to where() just like any other parameters. The put the question mark inside the parenthesis of your IN clause.

//sample parameter, a numeric key array
$params = array('3010001', '3010002', '3010003', '3010004');
//this example uses Zend_Db_Table
$select = $table->select()
    ->where('Scan_Number IN(?)', $params);

//the rest of the code

As simple as that.

This entry was posted in SQL, Zend Framework and tagged , , , , . Bookmark the permalink.

4 Responses to Zend Framework – Zend_Db In Clause

  1. jan says:


  2. Jamie Kahgee says:

    what if you have to escape your data? how would you do that?

  3. lysender says:

    @Jamie – Zend Framework will take care of that 😀

  4. Riska says:

    it works! zf 1.11
    собственно, я так и думал))

Leave a Reply

Your email address will not be published. Required fields are marked *