我有一个在PHP和MySQL的经验。在MYSQL中使用查询。*" SELECT * from Tablename" *从表中提取所有记录。*" SELECT * from Tablename" *
*" SELECT * from Tablename" *
yrdbyhpb1#
您可以使用MongoDB/Driver/Manager来完成此操作,如下所示
<?php $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017"); $bulk = new MongoDB\Driver\BulkWrite; $bulk->insert(['x' => 1]); $bulk->insert(['x' => 2]); $bulk->insert(['x' => 3]); $manager->executeBulkWrite('db.collection', $bulk); $filter = ['x' => ['$gt' => 1]]; $options = [ 'projection' => ['_id' => 0], 'sort' => ['x' => -1], ]; $query = new MongoDB\Driver\Query($filter, $options); $cursor = $manager->executeQuery('db.collection', $query); foreach ($cursor as $document) { var_dump($document); } ?>
1条答案
按热度按时间yrdbyhpb1#
您可以使用MongoDB/Driver/Manager来完成此操作,如下所示