在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
php本地环境: C:\mongodb4.0\bin 本地项目www/mongo 本地域名搭建mgo.cn (注意域名配置后还要修改host文件) 如果要mongo操作切换环境php5.6
/-----------------------------Command--------------------------------------------------/ 1 //manager mænɪdʒə主教练
2 //bulk baok大部分
3 $manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
4 $command =new MongoDB\Driver\Command([
5 'delete'=>'goods',// collection表名;次参数数组代码参考下方官方
6 'deletes'=> [
7 ['q'=>['price'=>"120"],'limit'=>0]
8 ]
9 ]);
10 $cursor = $manager->executeCommand('ecshop', $command);
11 var_dump($cursor->toArray()[0]);
12
Command资料 用法:https://blog.csdn.net/qq_33028267/article/details/88547137
$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017'); $command1 = new MongoDB\Driver\Command([//查出某一个 "find"=>"goods", "filter"=>["price"=>"130"] ]); $command2= new MongoDB\Driver\Command([//查出price字段的 "distinct"=>"goods", "key"=>"price", "query"=>["price"=>"120","price"=>"130"] ]); $command31 =new MongoDB\Driver\Command([ //插入 'insert'=>'goods',// collection表名 'documents'=> [ ['_id'=>time(), 'name'=> "栗子", 'price'=> "130" ], ['_id'=>time(), 'name'=> "核桃", 'price'=> "2250" ], ] ]); $command3 =new MongoDB\Driver\Command([ //插入 'insert'=>'goods',// collection表名 'documents'=> [ [ 'name'=> "栗子", 'price'=> "130" ], [ 'name'=> "核桃", 'price'=> "2250" ], ] ]);
|
2022-08-30
2022-08-17
2022-11-06
2022-08-17
2022-08-16
请发表评论