Пример #1
0
 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);
 }
Пример #2
0
 /**
  * @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']);
 }