2014-03-05 159 views
0

我試圖用我設置的鍵值進行查詢。php mongodb排序,查詢

這裏是什麼在DB

{ 
"_id": { 
    "$oid": "53166de3456a48980b00001f" 
}, 
"active": 1, 
"approved": 1, 
"date": "2014-03-04 16:20:51", 
"description": "flip blocks to form rows", 
"developer": "22", 
"iframe": "515", 
"image": "https://www.filepicker.io/api/file/f3eNFrgJRwqNprn7VLR0", 
"iosStore": "", 
"key": 1393978851, 
"leader": 0, 
    "leaderName": "Default", 
    "leaderScore": 0, 
    "platform": "html5", 
    "plays": 0, 
    "playStore": "", 
    "pot": 0, 
    "rules": "flip blocks to form rows", 
    "title": "tet_blocks", 
    "type": 1, 
    "web": "gamerholic.com/games/tetris/index.html" 
} 

,這裏是我的查詢:

 $key=1393978851 
    //tried it both with and without the new mongoID 
    $criteria = array(
    'key'=> new MongoId($key), 
    ); 

    $doc = $collectionBonsai->findOne($criteria); 
    $platform = $doc['platform']; 

平臺返回空,DOC返回空,當鑰匙顯然是在db和它在唯一的一個數據庫與該密鑰。關鍵是時間戳。 查找的_id也返回空, 如果我不通過用戶它列出它的文件中尋找..

我試過很多其他的發現變化和samething

響應 ARRA( )

回答

0

我把它改爲(INT)$鍵和現在的工作

+0

這的代碼實際上已經拋出無效的ObjectId – Sammaye

+0

它沒有......一個例外這個中斷東西只能有時 – user3052997

+0

什麼驅動VERS離子是這樣嗎? – Sammaye