1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-15 10:34:06 +02:00

remove operator @ in connect() methods

This commit is contained in:
David Grudl
2006-08-25 18:10:30 +00:00
parent 2cc9fa22fb
commit 36b88503f9
7 changed files with 42 additions and 25 deletions

View File

@@ -204,9 +204,13 @@ class dibi
*/
static public function getConnection($name = NULL)
{
return NULL === $name
? self::$conn
: @self::$registry[$name];
if (NULL === $name)
return self::$conn;
if (isset(self::$registry[$name]))
return self::$registry[$name];
return FALSE;
}

View File

@@ -48,14 +48,15 @@ class DibiMySqlDriver extends DibiDriver {
if (!extension_loaded('mysql'))
return new DibiException("PHP extension 'mysql' is not loaded");
foreach (array('username', 'password', 'protocol') as $var)
if (!isset($config[$var])) $config[$var] = NULL;
if (empty($config['host'])) $config['host'] = 'localhost';
if (@$config['protocol'] === 'unix') // host can be socket
if ($config['protocol'] === 'unix') // host can be socket
$host = ':' . $config['host'];
else
$host = $config['host'] . (empty($config['port']) ? '' : $config['port']);
$host = $config['host'] . (empty($config['port']) ? '' : ':'.$config['port']);
// some errors aren't handled. Must use $php_errormsg
if (function_exists('ini_set'))
@@ -63,9 +64,9 @@ class DibiMySqlDriver extends DibiDriver {
$php_errormsg = '';
if (empty($config['persistent']))
$conn = @mysql_connect($host, @$config['username'], @$config['password']);
$conn = @mysql_connect($host, $config['username'], $config['password']);
else
$conn = @mysql_pconnect($host, @$config['username'], @$config['password']);
$conn = @mysql_pconnect($host, $config['username'], $config['password']);
if (function_exists('ini_set'))
ini_set('track_errors', $save);

View File

@@ -48,7 +48,10 @@ class DibiMySqliDriver extends DibiDriver {
if (empty($config['host'])) $config['host'] = 'localhost';
$conn = @mysqli_connect($config['host'], @$config['username'], @$config['password'], @$config['database'], @$config['port']);
foreach (array('username', 'password', 'database', 'port') as $var)
if (!isset($config[$var])) $config[$var] = NULL;
$conn = @mysqli_connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
if (!$conn)
return new DibiException("Connecting error", array(

View File

@@ -45,10 +45,16 @@ class DibiOdbcDriver extends DibiDriver {
if (!extension_loaded('odbc'))
return new DibiException("PHP extension 'odbc' is not loaded");
if (@$config['persistent'])
$conn = @odbc_pconnect($config['database'], $config['username'], $config['password']);
else
if (!isset($config['username']))
return new DibiException("Username must be specified");
if (!isset($config['password']))
return new DibiException("Password must be specified");
if (empty($config['persistent']))
$conn = @odbc_connect($config['database'], $config['username'], $config['password']);
else
$conn = @odbc_pconnect($config['database'], $config['username'], $config['password']);
if (!is_resource($conn))
return new DibiException("Connecting error", array(

View File

@@ -49,11 +49,14 @@ class DibiSqliteDriver extends DibiDriver {
if (empty($config['database']))
return new DibiException("Database must be specified");
if (!isset($config['mode']))
$config['mode'] = 0666;
$errorMsg = '';
if (empty($config['persistent']))
$conn = @sqlite_open($config['database'], @$config['mode'], $errorMsg);
$conn = @sqlite_open($config['database'], $config['mode'], $errorMsg);
else
$conn = @sqlite_popen($config['database'], @$config['mode'], $errorMsg);
$conn = @sqlite_popen($config['database'], $config['mode'], $errorMsg);
if (!$conn)
return new DibiException("Connecting error", array(

View File

@@ -48,7 +48,7 @@ class DibiException extends Exception
public function getSql()
{
return @$this->info['sql'];
return $this->info['sql'];
}