簡體   English   中英

如何使用Codeigniter選擇不同的mongodb數據庫

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM