PHP-RQL

A PHP client driver for the RethinkDB query language (ReQL).

This project is maintained 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

Requirements

Installing

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