public function testOperations() { $sql = new Sql($this->pdo); $actual = $sql->insert('users', array('uid' => 7, 'name' => 'Gonzalo', 'surname' => 'Ayuso')); $this->assertTrue($actual); $actual = $sql->insert('users', array('uid' => 8, 'name' => 'Peter', 'surname' => 'Parker')); $this->assertTrue($actual); $data = $sql->select('users', array('uid' => 8)); $this->assertEquals('Peter', $data[0]['name']); $this->assertEquals('Parker', $data[0]['surname']); $sql->update('users', array('name' => 'gonzalo'), array('uid' => 7)); $data = $sql->select('users', array('uid' => 7)); $this->assertEquals('gonzalo', $data[0]['name']); $data = $sql->delete('users', array('uid' => 7)); $data = $sql->select('users', array('uid' => 7)); $this->assertTrue(count($data) == 0); $this->assertTrue($sql->getPDO() instanceof PDO); }
/** * @GET * @getSql(db=PG, toVariable=sql) * @view Index.twig */ public function service2(Sql $sql) { $data = $sql->select('users', array('id' => 1)); return array('name' => $data[0]['username']); }