mirror of
https://github.com/dg/dibi.git
synced 2025-08-08 15:16:58 +02:00
drivers implementing IDibiDriver and IDibiResultDriver together do not use $resultSet in IDibiDriver part
This commit is contained in:
@@ -115,7 +115,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
||||
{
|
||||
DibiDriverException::tryError();
|
||||
$resource = $this->inTransaction ? $this->transaction : $this->connection;
|
||||
$this->resultSet = ibase_query($resource, $sql);
|
||||
$res = ibase_query($resource, $sql);
|
||||
|
||||
if (DibiDriverException::catchError($msg)) {
|
||||
if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
|
||||
@@ -127,11 +127,12 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiResultD
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->resultSet === FALSE) {
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDriverException(ibase_errmsg(), ibase_errcode(), $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -93,13 +93,14 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->resultSet = @mssql_query($sql, $this->connection); // intentionally @
|
||||
$res = @mssql_query($sql, $this->connection); // intentionally @
|
||||
|
||||
if ($this->resultSet === FALSE) {
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDriverException(mssql_get_last_message(), 0, $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -35,6 +35,9 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
||||
/** @var resource Resultset resource */
|
||||
private $resultSet;
|
||||
|
||||
/** @var int|FALSE Affected rows */
|
||||
private $affectedRows = FALSE;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -94,14 +97,17 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->resultSet = sqlsrv_query($this->connection, $sql);
|
||||
$this->affectedRows = FALSE;
|
||||
$res = sqlsrv_query($this->connection, $sql);
|
||||
|
||||
if ($this->resultSet === FALSE) {
|
||||
if ($res === FALSE) {
|
||||
$info = sqlsrv_errors();
|
||||
throw new DibiDriverException($info[0]['message'], $info[0]['code'], $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = sqlsrv_rows_affected($res);
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +118,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver, IDibiResult
|
||||
*/
|
||||
public function getAffectedRows()
|
||||
{
|
||||
return sqlsrv_rows_affected($this->resultSet);
|
||||
return $this->affectedRows;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -156,16 +156,17 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv
|
||||
public function query($sql)
|
||||
{
|
||||
if ($this->buffered) {
|
||||
$this->resultSet = @mysql_query($sql, $this->connection); // intentionally @
|
||||
$res = @mysql_query($sql, $this->connection); // intentionally @
|
||||
} else {
|
||||
$this->resultSet = @mysql_unbuffered_query($sql, $this->connection); // intentionally @
|
||||
$res = @mysql_unbuffered_query($sql, $this->connection); // intentionally @
|
||||
}
|
||||
|
||||
if (mysql_errno($this->connection)) {
|
||||
throw new DibiDriverException(mysql_error($this->connection), mysql_errno($this->connection), $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -156,13 +156,14 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->resultSet = @mysqli_query($this->connection, $sql, $this->buffered ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); // intentionally @
|
||||
$res = @mysqli_query($this->connection, $sql, $this->buffered ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); // intentionally @
|
||||
|
||||
if (mysqli_errno($this->connection)) {
|
||||
throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection), $sql);
|
||||
}
|
||||
|
||||
return is_object($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_object($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -33,6 +33,9 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
/** @var resource Resultset resource */
|
||||
private $resultSet;
|
||||
|
||||
/** @var int|FALSE Affected rows */
|
||||
private $affectedRows = FALSE;
|
||||
|
||||
/** @var int Cursor */
|
||||
private $row = 0;
|
||||
|
||||
@@ -98,13 +101,16 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->resultSet = @odbc_exec($this->connection, $sql); // intentionally @
|
||||
$this->affectedRows = FALSE;
|
||||
$res = @odbc_exec($this->connection, $sql); // intentionally @
|
||||
|
||||
if ($this->resultSet === FALSE) {
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDriverException(odbc_errormsg($this->connection) . ' ' . odbc_error($this->connection), 0, $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = odbc_num_rows($res);
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +121,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiResultDrive
|
||||
*/
|
||||
public function getAffectedRows()
|
||||
{
|
||||
return odbc_num_rows($this->resultSet);
|
||||
return $this->affectedRows;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -99,19 +99,20 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->resultSet = oci_parse($this->connection, $sql);
|
||||
if ($this->resultSet) {
|
||||
oci_execute($this->resultSet, $this->autocommit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT);
|
||||
$err = oci_error($this->resultSet);
|
||||
$res = oci_parse($this->connection, $sql);
|
||||
if ($res) {
|
||||
oci_execute($res, $this->autocommit ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT);
|
||||
$err = oci_error($res);
|
||||
if ($err) {
|
||||
throw new DibiDriverException($err['message'], $err['code'], $sql);
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
} else {
|
||||
$err = oci_error($this->connection);
|
||||
throw new DibiDriverException($err['message'], $err['code'], $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,9 +105,9 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
||||
// must detect if SQL returns result set or num of affected rows
|
||||
$cmd = strtoupper(substr(ltrim($sql), 0, 6));
|
||||
static $list = array('UPDATE'=>1, 'DELETE'=>1, 'INSERT'=>1, 'REPLAC'=>1);
|
||||
$this->affectedRows = FALSE;
|
||||
|
||||
if (isset($list[$cmd])) {
|
||||
$this->resultSet = NULL;
|
||||
$this->affectedRows = $this->connection->exec($sql);
|
||||
|
||||
if ($this->affectedRows === FALSE) {
|
||||
@@ -115,18 +115,15 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver, IDibiResultDriver
|
||||
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
} else {
|
||||
$this->resultSet = $this->connection->query($sql);
|
||||
$this->affectedRows = FALSE;
|
||||
$res = $this->connection->query($sql);
|
||||
|
||||
if ($this->resultSet === FALSE) {
|
||||
if ($res === FALSE) {
|
||||
$err = $this->connection->errorInfo();
|
||||
throw new DibiDriverException("SQLSTATE[$err[0]]: $err[2]", $err[1], $sql);
|
||||
} else {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
|
||||
return $this->createResultDriver($this->resultSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
||||
/** @var resource Resultset resource */
|
||||
private $resultSet;
|
||||
|
||||
/** @var int|FALSE Affected rows */
|
||||
private $affectedRows = FALSE;
|
||||
|
||||
/** @var bool Escape method */
|
||||
private $escMethod = FALSE;
|
||||
|
||||
@@ -125,13 +128,18 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
||||
*/
|
||||
public function query($sql)
|
||||
{
|
||||
$this->resultSet = @pg_query($this->connection, $sql); // intentionally @
|
||||
$this->affectedRows = FALSE;
|
||||
$res = @pg_query($this->connection, $sql); // intentionally @
|
||||
|
||||
if ($this->resultSet === FALSE) {
|
||||
if ($res === FALSE) {
|
||||
throw new DibiDriverException(pg_last_error($this->connection), 0, $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) && pg_num_fields($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = pg_affected_rows($res);
|
||||
if (pg_num_fields($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +150,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
||||
*/
|
||||
public function getAffectedRows()
|
||||
{
|
||||
return pg_affected_rows($this->resultSet);
|
||||
return $this->affectedRows;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -122,15 +122,16 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiResultDri
|
||||
|
||||
DibiDriverException::tryError();
|
||||
if ($this->buffered) {
|
||||
$this->resultSet = sqlite_query($this->connection, $sql);
|
||||
$res = sqlite_query($this->connection, $sql);
|
||||
} else {
|
||||
$this->resultSet = sqlite_unbuffered_query($this->connection, $sql);
|
||||
$res = sqlite_unbuffered_query($this->connection, $sql);
|
||||
}
|
||||
if (DibiDriverException::catchError($msg)) {
|
||||
throw new DibiDriverException($msg, sqlite_last_error($this->connection), $sql);
|
||||
}
|
||||
|
||||
return is_resource($this->resultSet) ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif (is_resource($res)) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -115,12 +115,13 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiResultDr
|
||||
$sql = iconv($this->charset, $this->dbcharset . '//IGNORE', $sql);
|
||||
}
|
||||
|
||||
$this->resultSet = @$this->connection->query($sql); // intentionally @
|
||||
$res = @$this->connection->query($sql); // intentionally @
|
||||
if ($this->connection->lastErrorCode()) {
|
||||
throw new DibiDriverException($this->connection->lastErrorMsg(), $this->connection->lastErrorCode(), $sql);
|
||||
}
|
||||
|
||||
return $this->resultSet instanceof SQLite3Result ? $this->createResultDriver($this->resultSet) : NULL;
|
||||
} elseif ($res instanceof SQLite3Result) {
|
||||
return $this->createResultDriver($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user