1
0
mirror of https://github.com/dg/dibi.git synced 2025-10-20 09:16:30 +02:00

throwing exception on connect

This commit is contained in:
David Grudl
2006-11-13 06:32:16 +00:00
parent 11b294be44
commit f447a03c96
11 changed files with 78 additions and 92 deletions

View File

@@ -42,11 +42,12 @@ class DibiMySqlDriver extends DibiDriver {
/**
* Driver factory
* @throw DibiException
*/
public static function connect($config)
{
if (!extension_loaded('mysql'))
return new DibiException("PHP extension 'mysql' is not loaded");
throw new DibiException("PHP extension 'mysql' is not loaded");
foreach (array('username', 'password', 'protocol') as $var)
if (!isset($config[$var])) $config[$var] = NULL;
@@ -73,7 +74,7 @@ class DibiMySqlDriver extends DibiDriver {
if (!is_resource($conn))
return new DibiException("Connecting error", array(
throw new DibiException("Connecting error", array(
'message' => mysql_error() ? mysql_error() : $php_errormsg,
'code' => mysql_errno(),
));
@@ -87,7 +88,7 @@ class DibiMySqlDriver extends DibiDriver {
if (!empty($config['database'])) {
if (!@mysql_select_db($config['database'], $conn))
return new DibiException("Connecting error", array(
throw new DibiException("Connecting error", array(
'message' => mysql_error($conn),
'code' => mysql_errno($conn),
));