Skip to content

Zend_db fill in multiple placeholders

Jan 11, 2011 1 min read #zend-framework

This post is more than 18 months old. Technology changes quickly, so some of this content may be out of date (but that's not always the case). Please verify any technical or programming information against the current release.

I’ve been using Zend_db to create a query which does a simple search on three columns of a table. Fortunately, I found out that the where() statement handles single parameters intelligently when there are multiple placeholders. In the case that there are many placeholders but only one parameter, that parameter will be added to each of the placeholders the same.

For example, see this statement:

$select->where(
  'email like ? OR first_name like ? OR last_name like ?', 
  array('%' . $q . '%')
);
php