private function query($db, $stmt, $params)
{
assert('is_object($db)');
assert('is_string($stmt)');
assert('is_array($params)');
try {
$query = $db->prepare($stmt);
foreach ($params as $param => $value) {
if (is_array($value)) {
$query->bindValue(":{$param}", $value[0], $value[1] ? $value[1] : \PDO::PARAM_STR);
} else {
$query->bindValue(":{$param}", $value, \PDO::PARAM_STR);
}
}
$query->execute();
return $query;
} catch (\PDOException $e) {
$this->lastError = $db->errorInfo();
throw new \Exception("Database error: " . $e->getMessage());
}
}