Re: DataObjects find using LIKE operators

From: Date: Mon, 13 Sep 2004 18:21:25 +0000
Subject: Re: DataObjects find using LIKE operators
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14517@lists.php.net to get a copy of this message
On Mon, 13 Sep 2004 11:00:45 +0200, Markus Wolff <wolff@21st.de> wrote: > Bastien Leblanc wrote: > > > Dear users, > > > > Is there a way to query the database using LIKE operators rather =, I > > would like user to be able to search with wildcard (* or % or what ever). > > > > How would you treat that problem? > > $do = DB_DataObject::factory('myTable'); $search = '%whatever%'; //could easily come from $_REQUEST $db = $do->getDatabaseConnection(); $do->whereAdd('myField LIKE '.$db->quoteSmart($search)); > $do->whereAdd("myField LIKE '%anything%'"); > $do->find(); > while($do->fetch()) { > echo "Found: ".$do->myField."<br>\n"; > } > > Regards, > Markus > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.pear.general (#14517) next »