当前位置: 首页 > 后端技术 > PHP

使用PHP操作MongoDB数据库

时间:2023-03-29 13:59:42 PHP

1。连接MongoDB数据库(前提是已经安装了php-mongodb扩展)$config="mongodb://{$user}:{$pass}@{$host}:{$port}";$mongodb=新的\MongoDB\Driver\Manager($config);2.简单统计$command=new\MongoDB\Driver\Command(['count'=>$collection,'query'=>$filter]);$result=$mongodb->e??xecuteCommand($db,$command);

最新推荐
猜你喜欢