public function query($sql, $bind = [], $fetchMode = \PDO::FETCH_ASSOC)
{
$this->_sql = preg_replace('#\\[([a-z_][a-z0-9_]*)\\]#i', '`\\1`', $sql);
$this->_bind = $bind;
$this->_affectedRows = 0;
$this->fireEvent('db:beforeQuery');
try {
if (count($bind) !== 0) {
$statement = $this->_pdo->prepare($this->_sql);
$statement = $this->_executePrepared($statement, $bind);
} else {
$statement = $this->_pdo->query($this->_sql);
}
$this->_affectedRows = $statement->rowCount();
$statement->setFetchMode($fetchMode);
} catch (\PDOException $e) {
throw new DbException(':message . ' . PHP_EOL . 'SQL: ":sql"' . PHP_EOL . ' BIND: :bind', ['message' => $e->getMessage(), 'sql' => $this->_sql, 'bind' => json_encode($this->_bind, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)]);
}
$this->fireEvent('db:afterQuery');
return $statement;
}