1
0
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:
David Grudl
2006-11-22 12:55:24 +00:00
parent f447a03c96
commit 3b8766d376
17 changed files with 95 additions and 58 deletions

View File

@@ -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) {}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;
}