Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 Thinkphp 开发一个 Web 项目。现在我需要查询具有指定字段的 mongodb 并抑制 '_id' 字段。但是 '_id' 字段默认包含在结果集中。我知道在 mongodb 客户端可以使用以下代码来禁止 '_id' 字段,但是使用 PHP/Thinkphp 呢?</p>
db.inventory.find( { type: 'food' }, { _id:0 } )
可以使用 MongoModel 进行查询,用法类似 Mysql Model。
M('CollectionName')->where(array('type'=>'food'))->field('_id')->select();