VOOZH about

URL: http://danielmewes.github.io/php-rql/

⇱ PHP-RQL by danielmewes


PHP-RQL

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.

Updates

  • 05/30/2016 New release: PHP-RQL 2.3.0. Adds support for RethinkDB 2.3 user authentication and for the new fold term. Also comes with a number of bug fixes and smaller improvements.
  • 12/04/2015 New release: PHP-RQL 2.2.0. Adds support for the 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.
  • 09/20/2015 New release: PHP-RQL 2.1.0. Adds support for the 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>"))).

Requirements

  • PHP 5.3
  • RethinkDB 2.3

Installing

  • Use Composer: require: "danielmewes/php-rql": "dev-master"
  • Install manually:
    1. Download the ZIP file of this repository or clone it using git.
    2. Unpack it.
    3. Copy the rdb directory into the path of your PHP project, or your system's PHP path (e.g. /usr/share/php).

Example

<?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);

Attributions