Bluz\Db\Db::fetchAll PHP Method

fetchAll() public method

Example of usage $db->fetchAll("SELECT * FROM users WHERE ip = ?", ['192.168.1.1']);
public fetchAll ( string $sql, array $params = [] ) : array[]
$sql string SQL query with placeholders "SELECT * FROM users WHERE ip = :ip"
$params array params for query placeholders (optional) array (':ip' => '127.0.0.1')
return array[]
    public function fetchAll($sql, $params = [])
    {
        $stmt = $this->prepare($sql, $params);
        $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
        $this->ok();
        return $result;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * fetchAll
  */
 public function testFetchAll()
 {
     $result = $this->db->fetchAll("SELECT * FROM test LIMIT 10");
     $this->assertEquals(10, sizeof($result));
 }