0

How to add a not equal condition in phpactiverecords?

Code_reference::find('all', array('code' => $name), array('conditions' => 'id != '.$code_id))
4

2 回答 2

0

尝试使用<>

Code_reference::find('all', array('code' => $name), array('conditions' => 'id <> '.$code_id))
于 2012-07-09T09:42:43.170 回答
0

在您的示例中,第二个$options数组将被忽略。您必须自己合并它们,因此不能再使用紧凑的hash模式。

CodeReference::all(array('code = ? AND id != ?', $name, $code_id));

要打印 SQL 查询,您可以使用last_sql.

CodeReference::table()->last_sql

有关更多详细信息,请参阅官方(但滞后)文档:

http://www.phpactiverecord.org/projects/main/wiki/Finders#conditions

于 2012-07-10T16:07:43.397 回答