Answer the question
In order to leave comments, you need to log in
[SOLVED] MongoDB PHP and magic $OR
The following question arose ...
How to make a request from PHP to mongo with $OR
In mongo:
{ empl_type: { $in: [ 'programmers', 'admins' ] }, $or: [{ p_phone : true }, { a_phone: false}] }
In php:
swears:
Uncaught exception 'MongoCursorException' with message '$or requires nonempty array'
Maybe someone has already encountered and knows how to solve this issue?
$categories = array('programmers', 'admins');
$filters = array(
array('p_phone' => 'true'),
array('a_phone' => 'false'),
);
$data = $empls->find(array('empl_type' => array('$in' => $categories), '$or' => $filters));
Answer the question
In order to leave comments, you need to log in
pulled from a live project
$this->library('mongo')->find('guide', array('$or' => array(array('edited_uid' => $uid), array('created_uid' => $uid))));
Thanks for the answer =) But it didn't help. It turned out that true and false should be written as is, and not as a string.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question