所以我在做搜索飼料業主的$和我似乎有一個問題,當我去推$ _SESSION用戶PHP陣推MongoId
我用下面的代碼,以確保的MongoId當我們搜索ID是在相同的格式MongoId
new MongoId($_SESSION['user_information'][0]['_id'])
現在的代碼工作正常,只要我不認爲ID推到陣列
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;
}
它的這個部分是正在引起頭痛
//array_push($uid,new MongoId($_SESSION['user_information'][0]['_id']));
我首先看着array_push中的數組,它看起來沒問題。 推杆的SessionID在$其中print_r($where)
陣列([所有者] =>數組([$中] =>數組([0] => MongoId對象([$ ID] => 53b9ea3ae7fda8863c8b4568))))
與三IDS
Array ([owner] => Array ([$in] => Array ([0] => MongoId Object ([$id] => 53b9ea3ae7fda8863c8b4568) [1] => MongoId Object ([$id] => 53bf464ee7fda8780c8b4568) [2] => MongoId Object ([$id] => 53b00ab5e7fda8304b8b4567))))
他們看起來都一樣
現在這裏是什麼工作
Array ([owner] => Array ([$in] => Array ([0] => MongoId Object ([$id] => 53bf464ee7fda8780c8b4568) [1] => MongoId Object ([$id] => 53b00ab5e7fda8304b8b4567))))
,當腳本鰭ishes運行,我收到了飼料響應
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)))
現在是正確的
這裏是問題,因爲我看到它,有狀態後又名新聞發佈與$ _SESSION用戶ID
array (
'_id' => new MongoId("53bea75be7fda845298b4567"),
'owner' => new MongoId("53b9ea3ae7fda8863c8b4568"),
'status' => 'testing one more time',
'timestamp' => new MongoDate(1405003611, 394000),
)
因此,據我所知,這應該工作,我不知道爲什麼它不工作。 ID正確53b9ea3ae7fda8863c8b4568
但是當我做var_dump(static::db()->lastError());
所有UI得到的回覆是array(4) { ["n"]=> int(0) ["connectionId"]=> int(3277) ["err"]=> NULL ["ok"]=> float(1) }
我想知道如何解決這個問題,或者其他人看到的這個問題