/** * @param ISqlQuery $query * @param string $errormsg * @param integer $errorno */ function __construct(ISqlQuery $query, $errormsg, $errorno) { Assert::isScalar($errormsg); Assert::isNumeric($errorno); parent::__construct($errormsg, $errorno); $this->query = $query; }
function __construct($exceptionMessage, $exceptionCode, $dbMessage, $dbCode) { parent::__construct($exceptionMessage, $exceptionCode, $dbMessage, $dbCode); }
protected function handleException(DBException $ex) { // for now, print it. Maybe later, log it. add_notification($ex->getMessage()); }
public function __construct($message, $dupValue, $key) { parent::__construct($message, 1062, 23000); $this->dupValue = $dupValue; $this->dupKey = $key; }
/** * @param DB $dbHandle DB with failed connection parameters * @param string $errorMessage actual error string */ function __construct(DB $dbHandle, $errorMessage) { parent::__construct($errorMessage); $this->db = $dbHandle; }
/** * Executes SQL * * @param string * @param string * @param bool * @return mixed resource result or void if $expecting_results == false * @throws DBException */ public function execute($sql, $name = null, $expecting_results = false) { if (!$this->connected) { $this->connect(); } try { if ($expecting_results) { if (($res = mysql_query($sql, $this->connection)) === false) { throw new DBException(mysql_error($this->connection), mysql_errno($this->connection), $sql); } return $res; } else { mysql_unbuffered_query($sql, $this->connection); } } catch (PHPException $e) { $e->stripFunctionNames('mysql_unbuffered_query', 'mysql_query'); $e = new DBException($e, $e->getMessage()); $e->errorInfo = $sql; throw $e; } }
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; }
public function __construct($message = null, $rollback = false, $code = 0) { $this->rollback = $rollback; parent::__construct($message, $code); }