php mongodb Class 'MongoClient' not found

钱震博
2023-12-01

环境: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();
 类似资料:

相关阅读

相关文章

相关问答