bottledcode/php-rql

PHP客户端驱动程序,用于RethinkDB查询语言(ReQL)

dev-master 2023-06-13 16:46 UTC

This package is auto-updated.

Last update: 2024-09-13 19:28:02 UTC


README

PHP客户端驱动程序,用于RethinkDB查询语言(ReQL)。

PHP-RQL采用Apache License 2.0许可协议 https://apache.ac.cn/licenses/LICENSE-2.0

这是原始PHP-RQL项目的分支,针对PHP 8.2+进行了特定修改,使其更加友好。

持续集成

待定

文档

官方JavaScript驱动程序文档提供了更多关于可用术语的详细信息。大多数JavaScript驱动的示例只需稍作修改即可转换为PHP-RQL。

示例

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

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

归属