1. Go to this page and download the library: Download tcb13/sequel-mongo-php 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/ */
tcb13 / sequel-mongo-php example snippets
// Start a MongoDB Client to create a connection to your Database
$mongoConnection = new \MongoDB\Client("mongodb://127.0.0.1", [
"username" => "user",
"password" => "pass"
]);
/** @var \MongoDB\Database $mongo */
$mongo = $mongoConnection->selectDatabase("DatabaseName");
$qb = new QueryBuilder($mongo);
$qb->collection("Orders")
->select("id", new ArrayLength("prioritaryItems", "prioritaryItems_lenght"))
->where("prioritaryItems_lenght", ">", 0)
->findAll();
$result = $qb->toArray();
var_dump($result);
$qb = new QueryBuilder($mongo);
$qb->collection("Users")
->where("id", 123)
->update([
new ArrayPush("tokens", "...")
]);
$result = $qb->toArray();
var_dump($result);
$qb = new QueryBuilder($mongo);
$qb->collection("Users")
->where("id", 123)
->update([
new ArrayPull("tokens", "...")
]);
$result = $qb->toArray();
var_dump($result);
QueryBuilder::$pipelineDebug = true; // Enable pipeline debugging!
// Run a query
$result = (new QueryBuilder())->collection("xyz")
->where("active", true)
->findAll()
->toArray();
// Fetch the pipeline built by the Query Builder
var_dump(QueryBuilder::getLastPipelineLog()); // Get the pipeline built for the last query
var_dump(QueryBuilder::getPipelineLogs()); // Get all pipelines ever built by the query builder
shell
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.