PHP数组推MongoId

So I am doing an $in search for owners of feed and I seem to have an issue when I go to push the MongoId of the $_SESSION user

I use the following code to make sure when we search for the ID it is in the same format as MongoId

new MongoId($_SESSION['user_information'][0]['_id'])

Now the code works fine as long as I don't push that ID to the array

function feed(){
        $collection = static::db()->following;
        $following = $collection->findOne(array ('owner' => new MongoId($_SESSION['user_information'][0]['_id'])));
        $follow = $following['following'];
        $uid = array();
        //array_push($uid,new MongoId($_SESSION['user_information'][0]['_id']));
        foreach($following['following'] as $id)
        {
            array_push($uid,$id);
        }

        $where=array("owner" => array( '$in' =>$uid));
        $collection = static::db()->feed;
        $cursor = $collection->find($where);
        if ($cursor->count() == 1)
            {
                //print "found you";
                $feed = array();
                // iterate through the results
                while( $cursor->hasNext() ) {   
                    $feed[] = ($cursor->getNext());
                }
            }
            return $feed;
    }

it's this part that is causing the headache

//array_push($uid,new MongoId($_SESSION['user_information'][0]['_id']));

I first looked at the array from the array_push and it looks ok. putting SessionID in $where print_r($where) Array ( [owner] => Array ( [$in] => Array ( [0] => MongoId Object ( [$id] => 53b9ea3ae7fda8863c8b4568 ) ) ) )

With three ids

Array ( [owner] => Array ( [$in] => Array ( [0] => MongoId Object ( [$id] => 53b9ea3ae7fda8863c8b4568 ) [1] => MongoId Object ( [$id] => 53bf464ee7fda8780c8b4568 ) [2] => MongoId Object ( [$id] => 53b00ab5e7fda8304b8b4567 ) ) ) ) 

They all look the same

now here is what does work

Array ( [owner] => Array ( [$in] => Array ( [0] => MongoId Object ( [$id] => 53bf464ee7fda8780c8b4568 ) [1] => MongoId Object ( [$id] => 53b00ab5e7fda8304b8b4567 ) ) ) ) 

which when the script finishes running i get a feed response

Array ( [0] => Array ( [_id] => MongoId Object ( [$id] => 53bf4667e7fda8700e8b4567 ) [owner] => MongoId Object ( [$id] => 53bf464ee7fda8780c8b4568 ) [status] => love this video - Pedigree Shelter dogs http://youtube.com/watch?v=5v5Ui8HUuN8 [timestamp] => MongoDate Object ( [sec] => 1405044327 [usec] => 565000 ) ) )

Now that is correct

Here is the issue as I see it, There are status post aka feed post with the $_SESSION user id

array (
  '_id' => new MongoId("53bea75be7fda845298b4567"),
  'owner' => new MongoId("53b9ea3ae7fda8863c8b4568"),
  'status' => 'testing one more time',
  'timestamp' => new MongoDate(1405003611, 394000),
)

So as far as I see it this should work, and I am not sure why it is not working. the ID is correct 53b9ea3ae7fda8863c8b4568but when I do var_dump(static::db()->lastError()); All Ui get back is array(4) { ["n"]=> int(0) ["connectionId"]=> int(3277) ["err"]=> NULL ["ok"]=> float(1) }

I am wondering how to fix this or if anyone else see's this issue

the issue was simple

if ($cursor->count() == 1)

change that to

if ($cursor->count() >= 1)

It's amazing how one simple line can stop everything took 3 hours - just for one line.