插入数据
DB::Mongo()->selectCollection('loggers','coupons')->insert(array('a'=>1));
添加数据并获取添加数据和返回的数据
$attrs = DB::Mongo()->collection('loggers','coupons')->insert(array('a'=>1))->getAttrs();
添加数据并获取状态
$status = DB::Mongo()->collection('loggers','coupons')->insert(array('a'=>1))->getStatus();
###添加数据并获取插入的ID $id = DB::Mongo()->collection('loggers','coupons')->insert(array('a'=>1))->lastInsertId();
###查询所有数据 SQL等于 select * from loggers.coupons $data = DB::Mongo()->collection('loggers', 'coupons')->find();
###查询所有符合条件数据 SQL等于 select a from loggers.coupons where a=1 $data = DB::Mongo()->collection('loggers', 'coupons')->find(array('a' => 1), array('a')); foreach ($data as $key => $val) { print_r($val); }
#SQL 等于 select a from loggers.coupons where a=1 or a=2
#$data = DB::Mongo()->collection('loggers', 'coupons')->find(array('$or' => array(array('a' => 1), array('a' => 2))), array('a'));
#SQL 等于 select log_type from loggers.coupons where id='554ab308becb29dd820041a9'
#$data = DB::Mongo()->collection('loggers', 'coupons')->findOne(array('_id' => new \MongoId('554ab308becb29dd820041a9')), array('log_type'));
#查询ID
#$data = DB::Mongo()->collection('loggers', 'coupons')->findID('554ab308becb29dd820041a9');
###更新 #更新a=3的数据为name="YOHO" #$data = DB::Mongo()->collection('loggers', 'coupons')->update(array('a' => 3), array('name' => "YOHO"));
#SQL 等于 update loggers.coupons set test1='Mongo1' where test='Mongo'
#$data = DB::Mongo()->collection('loggers', 'coupons')->set()->update(array('test' => "Mongo"), array("test1" => "Mongo1"));
###删除 #SQL 等于 delete from loggers.coupons where id='55795b4cbecb297f610041a7' #$data = DB::Mongo()->collection('loggers', 'coupons')->remove(array('id' => new \MongoId('55795b4cbecb297f610041a7')));