private function exec($db, $stmt)
{
assert('is_object($db)');
assert('is_string($stmt)');
try {
return $db->exec($stmt);
} catch (\PDOException $e) {
$this->lastError = $db->errorInfo();
throw new \Exception("Database error: " . $e->getMessage());
}
}