/** * Create a new database connection instance. * * @param array $config */ public function __construct(array $config) { $this->config = $config; $this->database = $config['database']; $port = isset($config['port']) ? $config['port'] : 28015; $authKey = isset($config['authKey']) ? $config['authKey'] : null; // Create the connection $this->connection = r\connect($config['host'], $port, $this->database, $authKey); }
public function init() { if (!$this->conn) { $get = \PMVC\plug('get'); $host = $get->get('RETHINKDB_HOST'); if (!$host) { return; } $this->conn = r\connect($host, $get->get('RETHINKDB_PORT')); } var_dump($this->conn); $this['baseDb'] = __NAMESPACE__ . '\\BaseRethinkDB'; }
public function postAction(Request $request) { $content = $request->getContent(); if (!empty($content)) { $content = json_decode($content, true); // 2nd param of json_decode to get as array $conn = r\connect('localhost'); $post = r\db("todoapp")->table("list")->insert($content)->run($conn); $post = 'Done!'; } else { $post = 'nothing retreived from post...'; } return $this->render('VedranTodoBundle:Default:post.html.twig', array('post' => $post)); }
/** * Create a new database connection instance. * * @param array $config */ public function __construct(array $config) { $this->config = $config; $this->database = $config['database']; $port = isset($config['port']) ? $config['port'] : 28015; $authKey = isset($config['authKey']) ? $config['authKey'] : null; // Create the connection $this->connection = r\connect($config['host'], $port, $this->database, $authKey); // We need to initialize a query grammar and the query post processors, // which are both very important parts of the database abstractions - // so we initialize these to their default values when starting. $this->useDefaultQueryGrammar(); $this->useDefaultPostProcessor(); }