[英]How to select distinct mongodb database using Codeigniter
我是通过Codeigniter使用mongodb的新手。 我注意到Mongodb的一些活动记录与实例的sql非常相似
$this->db->get('mytable');
$this->mongo_db->get('mytable');
但是我遇到了一个问题,其中独特的东西不起作用:
$this->mongo_db->distinct('name');
$this->mongo_db->get('mytable');
一直在寻找这个,但找不到任何东西,有没有办法解决?
非常感谢
我正在使用此库用于CodeIgniter( https://github.com/alexbilbie/codeigniter-mongodb-library ),并且存在方法:switch_db($ db_name);
然后使用get可以选择巫婆集合(在MongoDB中的表是集合),就像您在示例中所做的那样:
$ this-> mongo_db-> get('collection_name');
您可以使用 :
$this->mongo_db->distinct('collection', 'field_name');
这将帮助您从集合中找到不同的价值。 确保已安装mongo_db库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.