1
0
mirror of https://github.com/dg/dibi.git synced 2025-10-23 10:46:07 +02:00

* removed $throwExceptions (always throws)

* added DibiLogger, dibi::notify(), dibi::startLogger()
* miniprofiler dibi::$numOfQueries, $totalTime, $elapsedTime
* simplified DibiException, added DibiDatabaseException
* Dibi::nativeQuery splitted into DibiDriver::doQuery & nativeQuery()
* moved dibi::dumpResult -> DibiResult::dump()
* moved dibi::test() -> DibiDriver::test()
* DibiTranslator generates $mask
This commit is contained in:
David Grudl
2007-09-29 07:53:25 +00:00
parent 0d8478d1d3
commit d35a850311
26 changed files with 689 additions and 703 deletions

View File

@@ -12,28 +12,29 @@
*/
// security - include dibi.php, not this file
if (!class_exists('dibi', FALSE)) die();
/**
* dibi exception class
*
* dibi common exception
*/
class DibiException extends Exception
{
private
$sql,
$dbError;
}
public function __construct($message, $dbError = NULL, $sql = NULL)
/**
* database server exception
*/
class DibiDatabaseException extends DibiException
{
/** @var string */
private $sql;
public function __construct($message = NULL, $code = 0, $sql = NULL)
{
$this->dbError = $dbError;
$this->sql = $sql;
parent::__construct($message);
$this->sql = $sql;
dibi::notify('exception', NULL, $this);
}
@@ -45,31 +46,13 @@ class DibiException extends Exception
final public function getDbError()
{
return $this->dbError;
}
public function __toString()
{
$s = parent::__toString();
if ($this->dbError) {
$s .= "\n\nDatabase error: ";
if (isset($this->dbError['code'])) {
$s .= "[" . $this->dbError['code'] . "] ";
}
$s .= $this->dbError['message'];
}
if ($this->sql) {
$s .= "\nSQL: " . $this->sql;
}
return $s;
}
} // class DibiException
}