本文主要是介绍php mongodb Class 'MongoClient' not found,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
环境:windows 7
1 从 http://pecl.php.net/package/mongo/1.6.14/windows 下载了最新的mongodb扩展mongo 1.6.14
2 将php_mongo.dll复制到php/ext/
3 php.ini配置,添加一行extension=php_mongo.dll
4 cli下查看phpinfo(),可以看到mongo模块
可是运行代码时,出现Class ‘MongoClient’ not found错误
一般是dll的类型不对,刚开始下载的是 5.6 Non Thread Safe (NTS) x86
后来下载5.6 Thread Safe (TS) x86就ok了
<?php
$conn = new MongoClient();
$db = $conn->selectDB('cvm');
$collection = $db->cvm_info;
$cursor = $collection->find(['woodpeck_job_status' => 0]);
foreach ($cursor as $obj) {$jobId = $obj['woodpeck_jobid'];echo $jobId;$data = ['woodpeck_job_status' => 1,'woodpeck_ping' => 1,'woodpeck_login' => 0,'woodpeck_performance' => 0,'woodpeck_diskio' => 0,];$collection->update(['woodpeck_jobid' => $jobId], ['$set' => $data]);
}
$conn->close();
这篇关于php mongodb Class 'MongoClient' not found的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!