Nilam Doctor
Nilam Doctor

Reputation: 491

Lithium: find list with condition not in a array

I am trying to use the find for a list having fields = name and the field "number" NOT in a list of array $importedVolumes.

$importedVolumes = array('22','38');

   Volumes::find('list', array(
    "fields"=>"name",
    "conditions"=>array("number"=> 
      array("NOT IN"=>$importedVolumes)
     ),
    "order"=>"number ASC"
  ));

The above gives a null array.

Upvotes: 1

Views: 424

Answers (1)

Mehdi Lahmam B.
Mehdi Lahmam B.

Reputation: 2270

Since you are using MongoDB, use $nin operator

'conditions' => array(
    'number' => array('$nin' => $importedVolumes)
 )

Upvotes: 2

Related Questions