1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-24 02:43:09 +01:00
php-dibi/dibi/libs/DibiException.php

93 lines
2.0 KiB
PHP
Raw Normal View History

2006-06-04 23:06:33 +00:00
<?php
/**
* dibi - tiny'n'smart database abstraction layer
* ----------------------------------------------
*
* Copyright (c) 2005, 2007 David Grudl aka -dgx- (http://www.dgx.cz)
*
* This source file is subject to the "dibi license" that is bundled
* with this package in the file license.txt.
*
* For more information please see http://php7.org/dibi/
2006-06-04 23:06:33 +00:00
*
* @copyright Copyright (c) 2005, 2007 David Grudl
* @license http://php7.org/dibi/license dibi license
* @link http://php7.org/dibi/
* @package dibi
2006-06-04 23:06:33 +00:00
*/
/**
* dibi common exception
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl
* @package dibi
* @version $Revision$ $Date$
*/
2007-11-18 02:29:11 +00:00
class DibiException extends NException
{
}
2006-06-04 23:06:33 +00:00
/**
* database server exception
*
* @author David Grudl
* @copyright Copyright (c) 2005, 2007 David Grudl
* @package dibi
* @version $Revision$ $Date$
2006-06-04 23:06:33 +00:00
*/
class DibiDriverException extends DibiException
2006-06-04 23:06:33 +00:00
{
/** @var string */
private $sql;
2006-06-04 23:06:33 +00:00
/**
* Construct an dibi driver exception
*
* @param string Message describing the exception
* @param int Some code
* @param string SQL command
*/
public function __construct($message = NULL, $code = 0, $sql = NULL)
{
2007-11-12 14:35:55 +00:00
parent::__construct($message, (int) $code);
$this->sql = $sql;
dibi::notify(NULL, 'exception', $this);
2006-06-04 23:06:33 +00:00
}
/**
* @return string The SQL passed to the constructor
*/
final public function getSql()
2006-06-04 23:06:33 +00:00
{
return $this->sql;
}
/**
* @return string string represenation of exception with SQL command
*/
public function __toString()
{
return parent::__toString() . ($this->sql ? "\nSQL: " . $this->sql : '');
}
2006-06-04 23:06:33 +00:00
/**
* @see NException::catchError (this is Late static binding fix
*/
public static function catchError($class = __CLASS__)
{
parent::catchError($class);
}
}