mirror of
https://github.com/dg/dibi.git
synced 2025-08-12 00:54:11 +02:00
* throwing exception in DibiTranslator and DibiDriver
+ added dibi::$errorMode
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* This source file is subject to the GNU GPL license.
|
||||
*
|
||||
* @author David Grudl aka -dgx- <dave@dgx.cz>
|
||||
* @link http://texy.info/dibi/
|
||||
* @link http://dibi.texy.info/
|
||||
* @copyright Copyright (c) 2005-2006 David Grudl
|
||||
* @license GNU GENERAL PUBLIC LICENSE v2
|
||||
* @package dibi
|
||||
@@ -51,9 +51,10 @@ abstract class DibiDriver
|
||||
* DibiDriver factory: creates object and connects to a database
|
||||
*
|
||||
* @param array connect configuration
|
||||
* @return bool|object DibiDriver object on success, FALSE or Exception on failure
|
||||
* @return DibiDriver
|
||||
* @throw DibiException
|
||||
*/
|
||||
/*abstract PHP 5.2*/ static public function connect($config) {}
|
||||
/*abstract disallowed PHP 5.2*/ static public function connect($config) {}
|
||||
|
||||
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* This source file is subject to the GNU GPL license.
|
||||
*
|
||||
* @author David Grudl aka -dgx- <dave@dgx.cz>
|
||||
* @link http://texy.info/dibi/
|
||||
* @link http://dibi.texy.info/
|
||||
* @copyright Copyright (c) 2005-2006 David Grudl
|
||||
* @license GNU GENERAL PUBLIC LICENSE v2
|
||||
* @package dibi
|
||||
@@ -55,16 +55,12 @@ class DibiException extends Exception
|
||||
}
|
||||
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$s = parent::__toString();
|
||||
if (isset($this->info['sql']))
|
||||
$s .= "\nSQL: " . $this->info['sql'];
|
||||
return $s;
|
||||
}
|
||||
|
||||
} // class DibiException
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks result state
|
||||
*/
|
||||
function is_error($var)
|
||||
{
|
||||
return ($var === FALSE) || ($var instanceof Exception);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* This source file is subject to the GNU GPL license.
|
||||
*
|
||||
* @author David Grudl aka -dgx- <dave@dgx.cz>
|
||||
* @link http://texy.info/dibi/
|
||||
* @link http://dibi.texy.info/
|
||||
* @copyright Copyright (c) 2005-2006 David Grudl
|
||||
* @license GNU GENERAL PUBLIC LICENSE v2
|
||||
* @package dibi
|
||||
|
@@ -7,7 +7,7 @@
|
||||
* This source file is subject to the GNU GPL license.
|
||||
*
|
||||
* @author David Grudl aka -dgx- <dave@dgx.cz>
|
||||
* @link http://texy.info/dibi/
|
||||
* @link http://dibi.texy.info/
|
||||
* @copyright Copyright (c) 2005-2006 David Grudl
|
||||
* @license GNU GENERAL PUBLIC LICENSE v2
|
||||
* @package dibi
|
||||
@@ -50,6 +50,7 @@ class DibiTranslator
|
||||
*
|
||||
* @param array
|
||||
* @return string
|
||||
* @throw DibiException
|
||||
*/
|
||||
public function translate($args)
|
||||
{
|
||||
@@ -109,7 +110,7 @@ class DibiTranslator
|
||||
$sql = preg_replace('#\/\*.*?\*\/#s', '', $sql);
|
||||
|
||||
if ($this->hasError)
|
||||
return new DibiException('Errors during generating SQL', array('sql' => $sql));
|
||||
throw new DibiException('Errors during generating SQL', array('sql' => $sql));
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
Reference in New Issue
Block a user