PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of walid laggoune   MongoDB Queue PHP Query Execute   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: MongoDB Queue PHP Query Execute
Query and execute multiple queries using MongoDB
Author: By
Last change:
Date: 4 years ago
Size: 881 bytes
 

Contents

Class file image Download
<?php
require_once __DIR__ . "/vendor/autoload.php";
$collection = (new MongoDB\Client)->myDb;
$m = new MongoConcurrency\Mongo($collection);
$textData = [];
$options = [];
$intData = [];
echo
"Generating test data ... ";
for (
$i=1; $i <= 10000 ; $i++) {
   
array_push($intData, [$i => $i]);
}
for (
$i=0; $i <= 5000 ; $i++) {
   
array_push($textData, ["name" => "john"]);
}
echo
"[+] \n";

$m->selectFrom("test1", [], 3, function(iterable $results) {
    echo
" [+] End select : ".sizeof($results)."\n";
});
$m->insertTo("test2", $textData, 3, function() {
    echo
" [+] End insert \n";
});
$m->updateFrom("test2", ["name" => "john"], ["name" => "alex"], 3, function(int $modified) {
    echo
" [+] End update : ".$modified." \n";
});
$m->deleteFrom("test2", ["name" => "john"], 3, function(int $intDataeleted) {
    echo
" [+] End delete : ".$intDataeleted."\n";
});
$m->run();