使用PHP操作MongoDB数据库

1.连接MongoDB数据库(在已安装php-mongodb扩展的前提下)


$config = "mongodb://{$user}:{$pass}@{$host}:{$port}";
$mongodb = new \MongoDB\Driver\Manager($config );

2.简单统计


$command = new \MongoDB\Driver\Command(['count' => $collection,'query'=>$filter]);
$result = $mongodb->executeCommand($db,$command);

原文地址:https://segmentfault.com/a/1190000016113918

猜你喜欢

转载自www.cnblogs.com/lalalagq/p/9974797.html