distinct selects in lithium

若如初见. 提交于 2019-12-21 06:27:27

问题


Using Lithiums Model, how do you achieve getting a distinct result set of specific fields from a collection in MongoDB?

mongo query:

db.blogs.distinct('url');

回答1:


There currently isn't a way to do this elegantly to my knowledge. You can get results by working with the Pecl MongoDB object directly. The command function allows you to make any call you want.

$db = Connections::get('default');
$blogs = $db->connection->command(array('distinct'=>'blogs', 'key'=>'url'));


来源:https://stackoverflow.com/questions/5750561/distinct-selects-in-lithium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!