时间:2021-07-01 10:21:17 帮助过:14人阅读
wget http://pecl.php.net/get/mongodb-1.2.4.tgz tar zxf mongodb-1.2.4.tgz cd mongodb-1.2.4 /application/php/bin/phpize ./configure --with-php-config=/application/php/bin/php-config make make install Installing shared extensions: /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/
cd /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/ ls mongodb.so mongodb.so
vim /application/php/lib/php.ini ... extension=redis.so #添加此行 ...
<?php $manager = new MongoDB\Driver\Manager("mongodb://127.0.0.1:27017"); $bulk = new MongoDB\Driver\BulkWrite; $bulk->insert([‘x‘ => 1, ‘class‘=>‘toefl‘, ‘num‘ => ‘18‘]); $bulk->insert([‘x‘ => 2, ‘class‘=>‘ielts‘, ‘num‘ => ‘26‘]); $bulk->insert([‘x‘ => 3, ‘class‘=>‘sat‘, ‘num‘ => ‘35‘]); $manager->executeBulkWrite(‘test.log‘, $bulk); $filter = [‘x‘ => [‘$gt‘ => 1]]; $options = [ ‘projection‘ => [‘_id‘ => 0], ‘sort‘ => [‘x‘ => -1], ]; $query = new MongoDB\Driver\Query($filter, $options); $cursor = $manager->executeQuery(‘test.log‘, $query); foreach ($cursor as $document) { print_r($document); }
安装mongodb插件
标签:class filter app php-fpm 安装 测试 test get highlight