Skip to content

michaldudek/php-rql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP-RQL

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

PHP-RQL is licensed under the terms of the Apache License 2.0 http://www.apache.org/licenses/LICENSE-2.0

Overview

PHP-RQL provides a driver to access RethinkDB databases from PHP code.

It currently implements the query language and wire protocol of RethinkDB 1.4.x

The API of the driver is generally close to that of the official RethinkDB JavaScript driver.

Preliminary documentation is available at: http://dmewes.com/~daniel/php-rql-api/#ph (except for the PHP examples, the documentation is a copy of the official RethinkDB API docs)

Requirements

PHP 5.3

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\db("test")->table("tablePhpTest")->insert($document)->run($conn);
    echo "Insert: $result\n";

    // How many documents are in the table?
    $result = r\db("test")->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\db("test")->table("tablePhpTest")->map(function($x) {
            return $x('someKey');
        })->run($conn);
            
    foreach ($result as $doc) {
        echo "Doc: $doc\n";
    }
       
    // Delete the test table
    r\db("test")->tableDrop("tablePhpTest")->run($conn);
?>

Attributions

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 91.1%
  • Python 8.9%