PHP code example of danielmewes / php-rql
1. Go to this page and download the library: Download danielmewes/php-rql library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
danielmewes / php-rql example snippets
// Load the driver
$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);