初めてmongodbを使用し、単純なはずの何かに遭遇しましたが、それを機能させることができません。次のような Persons コレクションがあります。
{
"_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 にかなり慣れています。
これにより、Alex Rodriguez の代わりに Cool Dude が返されます。
ヘルプやポインタをありがとう。