How to specify multiple conditions and the type of condition using Zend_Db_Table

Posted by Mario on Stack Overflow See other posts from Stack Overflow or by Mario
Published on 2010-05-11T21:48:28Z Indexed on 2010/05/11 21:54 UTC
Read the original article Hit count: 212

Filed under:
|
|

I have a function in my model that I need to use multiple conditions when querying. Additionally I would like to also have partial matches.

I currently have:

public function searchClient($search_term)
{
$rows = $this->fetchAll(
    $this->select()
    ->where('first_name = ?', $search_term)
    );  
    return $rows->toArray();
}

Which is the equivalent of "SELECT * FROM clients WHERE first_name = 'foobar';"

I would like to have a function that is the equivalent of "SELECT * FROM clients WHERE first_name LIKE '%foobar%' OR last_name LIKE '%foobar%' OR home_phone LIKE '%foobar%';"

How would I create such a query within Zend_Db_Table?

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about zf