protected function getConnection() { static $connection; if (!isset($connection)) { $connection = \r\connect(getenv('RDB_HOST'), getenv('RDB_PORT'), getenv('RDB_DB')); } return $connection; }
public function setUp() { $this->connection = \r\connect('localhost'); // create table if not exists if (!$this->hasTable()) { $this->createTable(); } $this->eventStore = new RethinkDbEventStore($this->connection, \r\table($this->tableName), new DomainMessageSerializer(new SimpleInterfaceSerializer(), new SimpleInterfaceSerializer())); }
<table class="footable table table-stripped" data-page-size="10" data-filter=#filter> <thead> <tr> <th>Description</th> <th>Category</th> <th>Tags</th> <th data-hide="phone,tablet">URL</th> <th>Location</th> <th>Awareness</th> </tr> </thead> <tbody> <?php require_once __DIR__ . '/vendor/autoload.php'; $conn = r\connect('52.20.101.105'); $result = r\db("web")->table('ideas')->run($conn); foreach ($result as $doc) { if (isset($doc['IdeaDescription'])) { $retrieve_id = $doc[id]; echo "<tr class=\"gradeX\">"; echo "<td>" . $doc['IdeaDescription'] . "<br>"; echo "<form class=\"form-horizontal\" method=\"post\" id=\"retrieve\" action=\"retrieve_idea.php\">\r\n\t\t\t <br/><br/><br/>\r\n\t\t\t <button input type=\"submit\" class=\"btn btn-sm btn-primary m-t-n-xs\" name='idea_identifier' value=\"{$retrieve_id}\" style=\"width:40%\" type=\"button\"><strong>View/Edit Details</strong></button>\r\n\t\t\t\t </form>\r\n\t\t\t "; echo "<td>" . $doc['IdeaCategory'] . "</td>"; echo "<td>" . $doc['Tags'] . "</td>"; echo "<td>" . $doc['URL'] . "</td>"; echo "<td>" . $doc['GeographicLocation'] . " " . $doc['SpecificLocation'] . "</td>"; echo "<td>Coming soon</td>"; echo "</td></tr>"; } }
<?php require_once __DIR__ . '/../vendor/autoload.php'; // Connect to localhost $conn = r\connect('localhost'); // Create a test table $result = r\db("test")->tableCreate("tableExistsTest")->run($conn); // List tables $result = r\db("test")->tableList()->run($conn); var_dump($result); // Check if table exists $result = r\db("test")->tableList()->contains('tableExistsTest')->run($conn); var_dump($result); // Check if table exists $result = r\db("test")->tableList()->contains('tableExistsTest42')->run($conn); var_dump($result); // Delete the test table r\db("test")->tableDrop("tableExistsTest")->run($conn);
<?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); });
<?php include __DIR__ . '../../../vendor/autoload.php'; $conn = r\connect(getenv('RDB_HOST'), getenv('RDB_PORT')); $res = r\dbDrop(getenv('RDB_DB'))->run($conn);
} }); set_include_path($phpRqlIncludePath); require_once 'rdb/rdb.php'; require_once './Dataset.php'; require_once './TestCase.php'; // Include all data sets $datasetTypes = scandir('./Datasets'); foreach ($datasetTypes as $datasetType) { if ($datasetType[0] == ".") { continue; } require_once './Datasets/' . $datasetType; } // Establish a connection to the server $conn = r\connect($serverHost, $serverPort, null, $serverKey); // Include one test case at a time and run it $testCaseTypes = scandir('./TestCases'); $currentDatasets = array(); foreach ($testCaseTypes as $testCaseType) { if ($testCaseType[0] == ".") { continue; } $testCaseType = str_replace(".php", "", $testCaseType); if ($testCaseSelection && !in_array($testCaseType, $testCaseSelection)) { continue; } require_once './TestCases/' . $testCaseType . ".php"; $testCase = new $testCaseType($conn, $currentDatasets); echo "Running " . $testCaseType . "..."; $testCase->run();
} }); set_include_path($phpRqlIncludePath); require_once 'rdb/rdb.php'; require_once './Dataset.php'; require_once './TestCase.php'; // Include all data sets $datasetTypes = scandir('./Datasets'); foreach ($datasetTypes as $datasetType) { if ($datasetType[0] == ".") { continue; } require_once './Datasets/' . $datasetType; } // Establish a connection to the server $conn = r\connect($serverHost, $serverPort); // Include one test case at a time and run it $testCaseTypes = scandir('./TestCases'); $currentDatasets = array(); foreach ($testCaseTypes as $testCaseType) { if ($testCaseType[0] == ".") { continue; } $testCaseType = str_replace(".php", "", $testCaseType); if ($testCaseSelection && !in_array($testCaseType, $testCaseSelection)) { continue; } require_once './TestCases/' . $testCaseType . ".php"; $testCase = new $testCaseType($conn, $currentDatasets); echo "Running " . $testCaseType . "..."; $testCase->run();
private function db_connect() { $this->output("Connect to RethinkDB\r\n"); $start = microtime(true); try { $this->conn = r\connect($this->host, $this->port); } catch (RqlDriverError $e) { echo $e->getMessage() . "\n"; } catch (Exception $e) { echo sprintf("Cannot connect to RDB: %s \n", $e->getMessage()); exit(0); } $delta = microtime(true) - $start; $this->output(sprintf("\tConnected in %0.2f secs\r\n", $delta)); }
public function __construct() { $this->conn = \r\connect('localhost', 28015, 'paravo', 'superSecure'); }