News:
id | title | sub
1 | one | sub1
2 | two | sub2
public function executeSearch(sfWebRequest $request)
{
$q = Doctrine_Core::getTable('News')
->createQuery('a')
->where("a.title LIKE %?%", array($request->getParameter('text')));
if ($request->getParameter('sub')){
$q->andWhere('a.subtile = sub2');
}
$test = $q->execute();
}
if i send title = one then show me ok, same as if title = two, but if i entered in input search “one two” then this not working. How change SQL query and code for this? I would like if i entered “one two”, then show me title id 1 and title id 2. Now nothing show.
You need to break the search query to words, and add them all to the doctrine query: