1
0
mirror of https://github.com/dg/dibi.git synced 2025-10-21 17:58:02 +02:00

* modified DibiException (getDbError, ...)

* fix dibi::dumpResult()
This commit is contained in:
David Grudl
2007-02-02 03:51:43 +00:00
parent a2b1036a66
commit 0c86515076
16 changed files with 218 additions and 138 deletions

View File

@@ -28,31 +28,44 @@ if (!defined('DIBI')) die();
class DibiException extends Exception
{
private
$info;
$sql,
$dbError;
public function __construct($message, $info=NULL) {
$this->info = $info;
if (isset($info['message']))
$message = "$message: $info[message]";
public function __construct($message, $dbError=NULL, $sql=NULL)
{
$this->dbError = $dbError;
$this->sql = $sql;
parent::__construct($message);
}
public function getSql()
{
return isset($this->info['sql']) ? $this->info['sql'] : NULL;
return $this->sql;
}
public function getDbError()
{
return $this->dbError;
}
public function __toString()
{
$s = parent::__toString();
if (isset($this->info['sql']))
$s .= "\nSQL: " . $this->info['sql'];
if ($this->dbError) {
$s .= "\nERROR: ";
if (isset($this->dbError['code']))
$s .= "[" . $this->dbError['code'] . "] ";
$s .= $this->dbError['message'];
}
if ($this->sql) $s .= "\nSQL: " . $this->sql;
return $s;
}