php中的Mongodb简单查找

php中的Mongodb简单查找,mongodb,yii,Mongodb,Yii,第一次使用mongodb时,遇到了一些应该很简单的东西,但我就是无法让它工作。我有一个个人收藏,看起来像: { "_id": { "$oid": "50607a9a9a3f5fd402000000" }, "id": 1, "firstname": "Cool", "lastname": "Dude", "birthday": null, "country": null, "friends": [], "co

第一次使用mongodb时,遇到了一些应该很简单的东西,但我就是无法让它工作。我有一个个人收藏,看起来像:

{
    "_id": {
        "$oid": "50607a9a9a3f5fd402000000"
    },
    "id": 1,
    "firstname": "Cool",
    "lastname": "Dude",
    "birthday": null,
    "country": null,
    "friends": [],
    "comments": [],
    "wines": [],
    "avatar": null,
    "_status": null,
    "_salt": "1d8ebb2deca53a21c4a47422ecf2ae1a",
    "_password": null,
    "update_time": 1348500122,
    "creation_time": 1348500122
}
{
    "_id": {
        "$oid": "50607aed9a3f5fd402000001"
    },
    "id": 2,
    "firstname": "Alex",
    "lastname": "Rodriguez",
    "birthday": null,
    "country": null,
    "friends": [],
    "comments": [],
    "wines": [],
    "avatar": null,
    "_status": null,
    "_salt": "5e751eec310808fca425537cdc8a8453",
    "_password": null,
    "update_time": 1348500205,
    "creation_time": 1348500205
}
使用以下代码,我希望找到我要查找的记录:

$person = new Persons();

$person = $person->find(array('firstname' => 'Alex'));

var_dump($person);
我想我使用的是Yii框架中的EMongoDocument类。我刚从这里开始,对mysql非常熟悉

这是一个很酷的家伙,而不是亚历克斯·罗德里格斯


谢谢您的帮助和指点。

好的,我需要使用findByAttributes()

$person = $person->findByAttributes(array('firstname' => 'Cool'));