forked from danielmewes/php-rql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassic.php
More file actions
33 lines (25 loc) · 798 Bytes
/
classic.php
File metadata and controls
33 lines (25 loc) · 798 Bytes
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
<?php
// Load the driver
require_once("rdb/rdb.php");
// Connect to localhost
$conn = r\connect('localhost', 28015);
// Create a test table
r\db("test")->tableCreate("tablePhpTest")->run($conn);
// Insert a document
$document = array('someKey' => 'someValue');
$result = r\table("tablePhpTest")->insert($document)
->run($conn);
echo "Insert: $result\n";
// How many documents are in the table?
$result = r\table("tablePhpTest")->count()->run($conn);
echo "Count: $result\n";
// List the someKey values of the documents in the table
// (using a mapping-function)
$result = r\table("tablePhpTest")->map(function ($x) {
return $x('someKey');
})->run($conn);
foreach ($result as $doc) {
print_r($doc);
}
// Delete the test table
r\db("test")->tableDrop("tablePhpTest")->run($conn);