Working of OR operator in mongodb with php
$query = array(
'table' => $table,
'user_id' => array('$ne'=> null),
'$or' => array('movies' => array('$ne' => null), 'comics' => array('$ne' => null) )
);
$dbcollection->find($query);
Here I try to return whole records where movies array or comics array is not null, But I always return empty array. In database, movies or comics array is present in some records and some other records no movies or comics array is present.
How can I correct this query ?
The comments indicate that you are using MongoDB 1.4.4. The $or
operator did not get introduced until MongoDB 1.6 as per documentation. MongoDB 1.4.4 is also really really old. Please upgrade!