A PHP client driver for the RethinkDB query language (ReQL).
This project is maintained by danielmewes
PHP-RQL provides a driver to access RethinkDB databases from PHP code. It is licensed under the terms of the Apache License 2.0.
Read the example below or the API documentation to find out more.
fold
term. Also comes with a number of bug fixes and smaller improvements.values
term, the $conn->server()
command, and the optional r\uuid
string argument from RethinkDB 2.2. PHP-RQL now conforms to PSR2 and PSR4, thanks to a major refactoring by @mbrevda. The testing system is now based on PHPUnit.floor
, ceil
and round
terms from RethinkDB 2.1. Added support for SSL connections. To connect to an SSL host, use r\connect(array("host" => "<hostname>", "port" => <port>, "apiKey" => "<api key>", "ssl" => array("cafile" => "<path to ca cert>")))
.require: "danielmewes/php-rql": "dev-master"
rdb
directory into the path of your PHP project, or your system's PHP path (e.g. /usr/share/php
).<?php
// Load the driver
require_once("rdb/rdb.php");
// Connect to localhost
$conn = r\connect('localhost');
// 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";
print_r($result);
// 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);