Esempio n. 1
0
 public function run()
 {
     r\dbCreate('NoreplyTest')->run($this->conn);
     $this->conn->useDb('NoreplyTest');
     r\tableCreate('t')->run($this->conn);
     $result = r\table('t')->insert(array('id' => 1, 'key' => 'val'))->run($this->conn, array('noreply' => true));
     if (!is_null($result)) {
         echo "Noreply query returned a result\n";
     }
     $this->checkQueryResult(r\table('t')->get(1)->attr('key'), 'val');
     r\dbDrop('NoreplyTest')->run($this->conn);
 }
Esempio n. 2
0
 public function updateByPortId($deviceId, $portId, $status)
 {
     $driver = $this->getDriver();
     \r\table("devices")->get($deviceId)->update(['ports' => [$portId => ['status' => $status]]])->run($driver->conn);
 }
Esempio n. 3
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
get('/rethinkdb', function () {
    $conn = \r\connect('10.10.10.150');
    //\r\db("test")->tableCreate("tablePhpTest2")->run($conn);
    // Insert a document
    $document = array('someKey' => 'someValue');
    $result = \r\table("tablePhpTest")->insert($document)->run($conn);
    //dd($result);
    //\r\db("test")->tableDrop("tablePhpTest")->run($conn);
});
Esempio n. 4
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
// Connect to localhost
$conn = r\connect('localhost');
// Create a test table
$result = r\db("test")->tableCreate("tablePhpTest")->run($conn);
// Subscribe to the changes on a table
$feed = r\table('tablePhpTest')->changes()->run($conn);
foreach ($feed as $change) {
    print_r($change);
}
// Delete the test table
r\db("test")->tableDrop("tablePhpTest")->run($conn);
Esempio n. 5
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
// Connect to localhost
$conn = r\connect('localhost');
// Create a test table
$result = r\db("test")->tableCreate("tablePhpTest")->run($conn);
// Insert multiple documents
$document = [['foo' => 'bar'], ['bar' => 'baz']];
$result = r\table("tablePhpTest")->insert($document)->run($conn);
echo "Insert: " . var_export($result, true) . "\n";
// How many documents are in the table?
$result = r\table("tablePhpTest")->count()->run($conn);
echo "Count: {$result}\n";
// Delete the test table
r\db("test")->tableDrop("tablePhpTest")->run($conn);
 private function createTable()
 {
     \r\db($this->databaseName)->tableCreate($this->tableName)->run($this->connection);
     \r\table($this->tableName)->indexCreate('uuid')->run($this->connection);
     sleep(1);
 }
Esempio n. 7
0
// see https://github.com/othillo/php-rql/blob/master/README.md#example
<?php 
require_once __DIR__ . '/../vendor/autoload.php';
// Connect to localhost
$conn = r\connect('localhost');
// Create a test table
$result = r\db("test")->tableCreate("tablePhpTest")->run($conn);
// Insert a document
$document = array('someKey' => 'someValue');
$result = r\table("tablePhpTest")->insert($document)->run($conn);
echo "Insert: " . var_export($result, true) . "\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) {
    var_dump($doc);
}
// Delete the test table
r\db("test")->tableDrop("tablePhpTest")->run($conn);