我使用if,where和or子句构建了一个使用n_make和n_month搜索文本的查询
但是 - 不确定为什么n_month没有被执行,只搜索文本,如果它在n_make中而不在n_month中
我希望搜索显示输出,如果它显示在n_make或n_month
中 // Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->Quote('%' . $db->escape($search, true) . '%');
$query->where('( a.n_make LIKE ' . $search . ' )')
or
$query->where('( a.n_month LIKE ' . $search . ' )')
;
}
}
答案 0 :(得分:1)
else
{
$search = $db->Quote('%' . $db->escape($search, true) . '%');
$query->where('( a.n_make LIKE' . $search . ') OR ( a.n_month LIKE' . $search . ')');
}