forked from danielmewes/php-rql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathporky.php
64 lines (61 loc) · 1.41 KB
/
porky.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
require_once('vendor/autoload.php');
/**
* Created by PhpStorm.
* User: vince
* Date: 16/02/2017
* Time: 20:33
*/
$loop = new \React\EventLoop\StreamSelectLoop();
\EventLoop\EventLoop::setLoop($loop);
// Connect to localhost
$conn = \Rxnet\await(r\connect('127.0.0.1', 28015));
echo " ! Connected ! ";
// Insert a document
$document = array('someKey' => 'someValue');
r\db("test")
// Create a test table
->tableCreate("tablePhpTest")
->run($conn)
->subscribeCallback(
function () {
echo "Table created\n";
}
);
$loop->run();
/*
->doOnNext(
function ($result) {
echo "Insert: $result\n";
}
)
->concat(r\table("tablePhpTest")
->count()
->run($conn)
)
->doOnNext(
function ($result) {
echo "Count: $result\n";
}
)
->concat(r\table("tablePhpTest")
->map(
function ($x) {
return $x('someKey');
}
)->run($conn))
->doOnNext(
function ($result) {
// List the someKey values of the documents in the table
// (using a mapping-function)
foreach ($result as $doc) {
print_r($doc);
}
})
->concat(r\db("test")
->tableDrop("tablePhpTest")
->run($conn)
)->subscribeCallback(function () {
echo "Everything is clean";
});
*/