query() public method

Example of usage $db->query("SET NAMES 'utf8'");
public query ( string $sql, array $params = [], array $types = [] ) : integer
$sql string SQL query with placeholders "UPDATE users SET name = :name WHERE id = :id"
$params array params for query placeholders (optional) array (':name' => 'John', ':id' => '123')
$types array Types of params (optional) array (':name' => \PDO::PARAM_STR, ':id' => \PDO::PARAM_INT)
return integer the number of rows
Esempio n. 1
0
 /**
  * Transaction Fail
  */
 public function testTransactionFalse()
 {
     $result = $this->db->transaction(function () {
         $this->db->query('DELETE FROM test LIMIT 1');
         $this->db->query('DELETE FROM test LIMIT 1');
         $this->db->query('DELETE FROM test LIMIT 1');
         $this->db->query('DELETE FROM notexiststable LIMIT 1');
     });
     $this->assertFalse($result);
 }