public function query($sql)
{
// compile patterns
$sql = str_replace('{table}', $this->tableName, $sql);
$result = $this->connection->query($sql);
if ($this->connection->error) {
throw new Exception("Database query error: " . $this->connection->error . ", Statement: " . $sql, -1);
}
return $result;
}