Example #1
0
 protected function beforeHandle($action, $params)
 {
     if (isset($_SESSION['userId'])) {
         $this->currentUser = $this->db->selectRow('SELECT * FROM user WHERE id=' . (int) $_SESSION['userId']);
     }
     return null;
 }
Example #2
0
 public function testConditionBuilder()
 {
     $this->assertEquals('`a` IS NULL', $this->db->where('a', null));
     $this->assertEquals("`a`='4'", $this->db->where('a', 4));
     $this->assertEquals("`a` IN ('1','2','3')", $this->db->where('a', [1, 2, 3]));
     $this->assertEquals('`a` IS NULL', $this->db->where(array('a' => null)));
     $this->assertEquals("`a`='4'", $this->db->where(array('a' => 4)));
     $this->assertEquals("`a` IN ('1','2','3')", $this->db->where(array('a' => [1, 2, 3])));
     $this->assertEquals("`a`='4' AND `b`='as\\'d'", $this->db->where(array('a' => 4, 'b' => 'as\'d')));
 }
 public function selectOne($where)
 {
     return Utils::mapOne($this->db->selectRow("SELECT * FROM {$this->table} WHERE {$where}"), $this->class);
 }
Example #4
0
 /**
  * @expectedException \Vtk13\LibSql\SqlException
  * @expectedExceptionMessage You have an error in your SQL syntax;
  */
 public function testMisspelledDelete()
 {
     $this->db->delete('S E', 'q w');
 }