1. Go to this page and download the library: Download andydune/mongo-query library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andydune / mongo-query example snippets
$collection = (new MongoDB\Client)->shop->tobacco;
$cursor = $collection->find(['price' => ['$lt' => 1000]]);
$collection = (new MongoDB\Client)->shop->tobacco;
$cursor = $collection->find(['type' => ['$in' => ['virginia', 'latakia']]]); // 3 brackets at once
$collection = (new MongoDB\Client)->shop->tobacco;
$cursor = $collection->find((new Query)->field('price')->lessThan(1000)->get());
// or
$cursor = (new Query)->field('price')->lessThan(1000)->find($collection);
$collection = (new MongoDB\Client)->test->tobacco;
$cursor = $collection->find((new Query)->field('type')->in('virginia', 'latakia')->get());
// or
$cursor = (new Query)->field('type')->in('virginia', 'latakia')->find($collection)
$query = new Query(['date' => 'datetime']);
$query->field('date')->lt(time() - 60); // documents with date 60 seconds old
$query = new Query(['date' => 'datetime']);
$query->field('date')->between(date(time() - 60, 'Y-m-d H:i:s'), time()); // documents between date 60 seconds old and now
$query = new Query(['date' => 'datetime']);
$query->field('date')->between('- 5 days', '+ 5 minutes'); // 5 days before and 5 minutes to future
use AndyDune\DateTime\DateTime;
$query = new Query(['date' => 'datetime']);
$query->field('date')->eq(new DateTime());
php composer.phar
php composer.phar update
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.