2014-03-05 107 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