1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 09:34:30 +02:00

refactoring in drivers

This commit is contained in:
David Grudl
2008-09-04 18:18:58 +00:00
parent 52d2ecf5b0
commit f935968aa7
5 changed files with 43 additions and 83 deletions

View File

@@ -120,12 +120,18 @@ class DibiMySqliDriver extends /*Nette::*/Object implements IDibiDriver
// affects the character set used by mysql_real_escape_string() (was added in MySQL 5.0.7 and PHP 5.0.5, fixed in PHP 5.1.5)
$ok = @mysqli_set_charset($this->connection, $config['charset']); // intentionally @
}
if (!$ok) $ok = @mysqli_query($this->connection, "SET NAMES '$config[charset]'"); // intentionally @
if (!$ok) $this->throwException();
if (!$ok) {
$ok = @mysqli_query($this->connection, "SET NAMES '$config[charset]'"); // intentionally @
if (!$ok) {
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection));
}
}
}
if (isset($config['sqlmode'])) {
if (!@mysqli_query($this->connection, "SET sql_mode='$config[sqlmode]'")) $this->throwException(); // intentionally @
if (!@mysqli_query($this->connection, "SET sql_mode='$config[sqlmode]'")) { // intentionally @
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection));
}
}
$this->buffered = empty($config['unbuffered']);
@@ -157,7 +163,7 @@ class DibiMySqliDriver extends /*Nette::*/Object implements IDibiDriver
$this->resultSet = @mysqli_query($this->connection, $sql, $this->buffered ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); // intentionally @
if (mysqli_errno($this->connection)) {
$this->throwException($sql);
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection), $sql);
}
return is_object($this->resultSet) ? clone $this : NULL;
@@ -370,18 +376,6 @@ class DibiMySqliDriver extends /*Nette::*/Object implements IDibiDriver
/**
* Converts database error to DibiDriverException.
*
* @throws DibiDriverException
*/
protected function throwException($sql = NULL)
{
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection), $sql);
}
/**
* Returns the connection resource.
*