1

In terminal, this returns what I want:

db.test.find({"sessions": {"$gt":5}, "n_friends":{"$lt":5}});

However in PHP, I have not been successful yet. The last thing I've tried looked like this:

    $query = $collection->find( array(
        'sessions' => array( '$gt' => 1 ), 
        '$and' => array('n_friends' => array( '$lt' => 50 ) ) ) ); 
1
  • Nevermind I got it. Basically I just realized that : becomes => in PHP, and the {} become array() Commented Jul 4, 2013 at 3:23

1 Answer 1

4

You are overcomplicating it :)

<?php
$query = array(
    'sessions' => array( '$gt' => 1 ),
    'n_friends' => array( '$lt' => 50 ),
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.