【发布时间】:2011-08-17 22:07:03
【问题描述】:
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();
}
如果我发送 title = one 则显示 ok,与 title = two 相同,但如果我在输入搜索中输入“one two”,则这不起作用。如何为此更改 SQL 查询和代码?我想如果我输入“一二”,然后显示标题 id 1 和标题 id 2。现在什么都不显示。
【问题讨论】:
标签: php mysql sql symfony1 doctrine