Search for mongodb in PHP

1

I'm having trouble returning records with a date filter. I have the following JSON document:

{
        "_id": "111090485635468_1098582396886267",
        "1098582396886267_1098592810218559": {
            "fb_id": "1098582396886267_1098592810218559",
            "created_time": {
                "date": "2016-07-28 20:32:06.000000",
                "timezone_type": 1,
                "timezone": "+00:00"
            },
            "from": {
                "picture": {
                    "height": 261,
                    "is_silhouette": false,
                    "url": "https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xaf1\/v\/t1.0-1\/p148x148\/13179438_970835299696887_7000909019670413123_n.jpg?oh=b4f9ecf8f00f8cb22a02874ec0bc7d96&oe=5815B673&__gda__=1479588815_6a2efe74184209e4b419783f02250c5d",
                    "width": 148
                },
                "name": "Jhonathan Vinicius",
                "id": "1020748971372186"
            },
            "message": "Uma string qualquer...",
            "comment_count": 7,
            "like_count": 11,
            "last_update": "29\/07\/2016 22:36:13"
        }

I need to filter all records between dates, I've tried something like this:

...
  $user = $c_users->find(   ['_id.fb_id.created_time.date' => [ '$gte'=> "2016-01-29 00:00", '$lt' => "2016-07-30 00:00" ] ]);  
....

And it does not return anything to me. I'm grateful to anyone who can help!

    
asked by anonymous 30.07.2016 / 16:34

1 answer

1

Your reference to the field is wrong. Instead of _id.fb_id.created_time.date , use 1098582396886267_1098592810218559.created_time.date .

$user = $c_users
    ->find([
        '1098582396886267_1098592810218559.created_time.date' => [
            '$gte'=> '2016-01-29 00:00',
            '$lt' => '2016-07-30 00:00',
        ]
    ]);
    
31.07.2016 / 11:56