【发布时间】:2013-11-27 15:45:35
【问题描述】:
我有以下对象:
{
users: {
_id: "users",
entries:
[
{
_id: 1,
username: "taxicala",
password: "password"
},
{
_id: 2,
username: "guest",
password: "guest"
}
]
}
}
我只想选择“条目”数组中的一个用户。我正在尝试以下方法:
$entry = $this->_users->find(
array('entries' =>
array('$elemMatch' =>
array('username' => 'taxicala')
)
)
);
我得到的结果是一个空对象:
{ }
我无法通过 Google 或此处找到任何关于此的线索。难道我做错了什么?我错过了什么吗?还是 PHP 不支持“$elemMatch”?
谢谢!
【问题讨论】:
标签: php mongodb mongodb-query