My code is written in this way {code ...} the final SQL statement is {code ...} this SQL statement is actually wrong. It should be {code ...} how should I write it in the code? My code is written in this way.
$ids = '1,2,3,4';$conditions[]=array('id IN (?)'=> $ids);
The SQL statement is
SELECT ...ooxx... WHERE id IN ('1,2,3,4');
This SQL statement is actually wrong. It should be
SELECT ...ooxx... WHERE id IN (1,2,3,4);
How should I write it in the code?
Reply content:
My code is written in this way.
$ids = '1,2,3,4';$conditions[]=array('id IN (?)'=> $ids);
The SQL statement is
SELECT ...ooxx... WHERE id IN ('1,2,3,4');
This SQL statement is actually wrong. It should be
SELECT ...ooxx... WHERE id IN (1,2,3,4);
How should I write it in the code?
$conditions[] = array( 'id' => array(1, 2, 3, 4 ) );
You can set an array containing values after the corresponding field name to achieve the same effect as the SQL logic operator IN.
I don't need it for a long time... just pass the array in my memory...
Example...
$this->foo->find( 'all', array( 'conditions' => array( 'foo.bar' => array( 1, 2, 3, 4 ) )) );