-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
29 lines (28 loc) · 881 Bytes
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?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();