public static function q($sql) { //time every query $start_time = microtime(true); // execute the query $result = self::getDB()->query($sql); // how long the request took $duration = microtime(true) - $start_time; //log the query Log::addQuery('database', $sql, $duration); // is there a problem if ($result === false) { $error = self::getDB()->error; //create and throw an exception $exception = new DBException($error); $exception->setQuery($sql); throw $exception; } return $result; }