Name Last Update
..
Collection.php Loading commit data...
Cursor.php Loading commit data...
MongoCore.php Loading commit data...
MongoException.php Loading commit data...
MongoObject.php Loading commit data...
MongoPage.php Loading commit data...
MongoResult.php Loading commit data...
README.md Loading commit data...

插入数据

    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();
    原生返回状态数据
    ->getStatusData()

###添加数据并获取插入的ID

    $id = DB::Mongo()->collection('loggers','coupons')->insert(array('a'=>1))->lastInsertId();
    原生插入返回ID对象
    ->lastInsertMongoID()

###分页显示

    $data = DB::Mongo()->collection('loggers', 'coupons')->offset(1)->limit(2)->findAll();

###获取总数

    $data = DB::Mongo()->collection('loggers', 'coupons')->count(array('a'=1));

###查询所有数据

    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')));

###save

    $mo = DB::Mongo()->collection('loggers', 'coupons');
    $data = array('a' => 1, 'b' => 2);
    $mo->insert($data);
    $data['c'] = 1;
    $data = $mo->save($data);

    $mo = DB::Mongo()->collection('loggers', 'coupons');
    $data = $mo->find();
    foreach ($data as $val) {
        $val['yoho1'] = 'Me';
        $mo->save($val);
    }