2
[_id] => MongoId Object (
    [$id] => 5090ace3788a466769b3804e
)
[startdate] => MongoDate Object (
    [sec] => 1301616000
    [usec] => 0
)
[enddate] => MongoDate Object (
    [sec] => 1304121600
    [usec] => 0
)
[your_id] => 33902
[odd_blah] => blahblah
[cam_id] => 339
[cost] => 0.01
[iscurrent] => 
[damn_current] => Array (
)

$coll = $this->mongo_db->where('cam_id', 339)->get('collection_name);

这不返回任何内容。您可能会注意到我正在使用 https://github.com/alexbilbie/codeigniter-mongodb-library/tree/v2

我得到一个空数组。任何人都可以帮忙吗?这听起来很原始,但有点卡在这里。

4

1 回答 1

2

你非常接近,你需要把你的where语句放在一个数组中。

$coll = $this->mongo_db
    ->where(array('cam_id' => 339))
    ->get('collection_name');

我假设您使用的是 Alex Bilbie 的MongoDB CodeIgniter Library。他的文档确实过时了,更建议查看他的源代码注释以获取示例和函数所需的输入类型。

于 2012-11-02T22:13:28.743 回答