如何在同一 table 上的多个列中进行搜索? (无脂肪框架)

How to search in multiple columns on same table? (fat free framework)

我需要使用 fatfree 在多个列上搜索相同的查询。 这在一列上正常工作:

 $f3->set('list', $users->find(array('name LIKE ?','%'.$queries.'%')));

但是,如果我尝试:

 $f3->set('list', $users->find(array('name, email LIKE ?','%'.$queries.'%')));

我收到错误:

PDOStatement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' email LIKE '%invent%'' at line 1

我该怎么做?

此致。

应该是:

$f3->set('list', $users->find(array(
  'name LIKE ? OR email LIKE ?',
  '%'.$queries.'%',
  '%'.$queries.'%'
)));

注意:PDO 不允许两次使用相同的占位符,因此您必须提供两次相同的参数 ('%'.$queries.'%')。