David Di Biase wrote:
> 
> WHERE B.Name LIKE '%" . $db->quote($_GET['name']) . "%' OR B.Description
> LIKE '%" . $db->quote($_GET['description']) . "%'
> 

Here's how I would do this:

  $select->where('B.Name LIKE ?',  '%' . $_GET['name'] . '%')
  $select->orWhere('B.Description LIKE ?',  '%' . $_GET['name'] . '%')

In other words, concatenate the wildcards before you quote the value.

However, as a side note, I recommend against the use of LIKE '%string%'. 
This is an "anti-pattern" that I call "Poor Man's Search Engine".  This is
an inefficient way of doing full-text matching in SQL.

You'd be better off indexing your text data with a real search engine like
Lucene or Sphinx.  Lucene even has a PHP implementation in Zend Framework.

If you use MySQL's MyISAM storage engine, you can also use FULLTEXT indexing
as a feature of the database.

Regards,
Bill Karwin
-- 
View this message in context: 
http://www.nabble.com/Using-quote%28%29-method-in-LIKE-statements-tp19113687p19113882.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to