문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top