private function insertDummyData($container) { $db = new Db($container); $pdo = $db->getPDO('PG'); $this->assertTrue($pdo instanceof PDO); $pdo->exec("CREATE TABLE IF NOT EXISTS users (\n id INTEGER PRIMARY KEY,\n username TEXT)"); $pdo->exec("DELETE FROM users"); $pdo->exec("INSERT INTO users(id, username) VALUES (1, 'Gonzalo')"); }
public function testTransactional() { $request = Request::create('/index.html', 'GET'); $container = $this->getContainer($request); $db = new Db($container); $pdo = $db->getPDO('PG'); $pdo->exec("CREATE TABLE messages(id integer, area text, username text, message text) WITH (OIDS = FALSE);"); $pdo->transactional(function () use($pdo) { $pdo->getSql()->insert('messages', array('id' => 1, 'area' => 'area', 'username' => 'username', 'message' => 'message')); }); $pdo->exec("DROP TABLE messages"); }
/** * @GET * @view Index.twig */ public function htm(Db $db) { $data = $db->getPDO('PG')->getSql()->select('users', array('id' => 1)); return array('name' => $data[0]['username']); }