phpactiverecords - not equal to
-
19-06-2021 - |
문제
How to add a not equal condition in phpactiverecords?
Code_reference::find('all', array('code' => $name), array('conditions' => 'id != '.$code_id))
해결책
Try use <>
Code_reference::find('all', array('code' => $name), array('conditions' => 'id <> '.$code_id))
다른 팁
In your example, the second $options
array will get ignored. You have to merge them yourself and thus cannot use the compact hash-mode anymore.
CodeReference::all(array('code = ? AND id != ?', $name, $code_id));
To print the SQL query, you can use last_sql
.
CodeReference::table()->last_sql
For more details, please refer to the official (but yet laggy) documentation:
http://www.phpactiverecord.org/projects/main/wiki/Finders#conditions
제휴하지 않습니다 StackOverflow