mirror of
https://github.com/dg/dibi.git
synced 2025-08-11 00:24:19 +02:00
* removed variables $insertId & $affectedRows
This commit is contained in:
@@ -22,9 +22,6 @@ if (!class_exists('dibi', FALSE)) die();
|
||||
*/
|
||||
class DibiMSSqlDriver extends DibiDriver
|
||||
{
|
||||
private
|
||||
$affectedRows = FALSE;
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'TRUE' => "1",
|
||||
@@ -78,27 +75,25 @@ class DibiMSSqlDriver extends DibiDriver
|
||||
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
$connection = $this->getConnection();
|
||||
$res = @mssql_query($sql, $connection);
|
||||
$res = @mssql_query($sql, $this->getConnection());
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
if ($res === FALSE) {
|
||||
return FALSE;
|
||||
|
||||
$this->affectedRows = mssql_rows_affected($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res)) {
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiMSSqlResult($res);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->affectedRows;
|
||||
$rows = mssql_rows_affected($this->getConnection());
|
||||
return $rows < 0 ? FALSE : $rows;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,10 +22,6 @@ if (!class_exists('dibi', FALSE)) die();
|
||||
*/
|
||||
class DibiMySqlDriver extends DibiDriver
|
||||
{
|
||||
private
|
||||
$insertId = FALSE,
|
||||
$affectedRows = FALSE;
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'TRUE' => "1",
|
||||
@@ -115,37 +111,33 @@ class DibiMySqlDriver extends DibiDriver
|
||||
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$connection = $this->getConnection();
|
||||
$res = @mysql_query($sql, $connection);
|
||||
$res = @mysql_query($sql, $this->getConnection());
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
if ($res === FALSE) {
|
||||
return FALSE;
|
||||
|
||||
$this->affectedRows = mysql_affected_rows($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = mysql_insert_id($connection);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_resource($res)) {
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiMySqlResult($res);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->affectedRows;
|
||||
$rows = mysql_affected_rows($this->getConnection());
|
||||
return $rows < 0 ? FALSE : $rows;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function insertId()
|
||||
{
|
||||
return $this->insertId;
|
||||
$id = mysql_insert_id($this->getConnection());
|
||||
return $id < 1 ? FALSE : $id;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,10 +22,6 @@ if (!class_exists('dibi', FALSE)) die();
|
||||
*/
|
||||
class DibiMySqliDriver extends DibiDriver
|
||||
{
|
||||
private
|
||||
$insertId = FALSE,
|
||||
$affectedRows = FALSE;
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'TRUE' => "1",
|
||||
@@ -85,37 +81,33 @@ class DibiMySqliDriver extends DibiDriver
|
||||
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$connection = $this->getConnection();
|
||||
$res = @mysqli_query($connection, $sql);
|
||||
$res = @mysqli_query($this->getConnection(), $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
if ($res === FALSE) {
|
||||
return FALSE;
|
||||
|
||||
$this->affectedRows = mysqli_affected_rows($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = mysqli_insert_id($connection);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_object($res)) {
|
||||
} elseif (is_object($res)) {
|
||||
return new DibiMySqliResult($res);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->affectedRows;
|
||||
$rows = mysqli_affected_rows($this->getConnection());
|
||||
return $rows < 0 ? FALSE : $rows;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function insertId()
|
||||
{
|
||||
return $this->insertId;
|
||||
$id = mysqli_insert_id($this->getConnection());
|
||||
return $id < 1 ? FALSE : $id;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -91,20 +91,20 @@ class DibiOdbcDriver extends DibiDriver
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
$res = @odbc_exec($this->getConnection(), $sql);
|
||||
|
||||
$connection = $this->getConnection();
|
||||
$res = @odbc_exec($connection, $sql);
|
||||
if ($res === FALSE) {
|
||||
return FALSE;
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
} elseif (is_resource($res)) {
|
||||
$this->affectedRows = odbc_num_rows($res);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->affectedRows = odbc_num_rows($res);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res)) {
|
||||
return new DibiOdbcResult($res);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,8 +22,6 @@ if (!class_exists('dibi', FALSE)) die();
|
||||
*/
|
||||
class DibiPdoDriver extends DibiDriver
|
||||
{
|
||||
private $affectedRows = FALSE;
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'TRUE' => "1",
|
||||
@@ -65,25 +63,25 @@ class DibiPdoDriver extends DibiDriver
|
||||
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
|
||||
// TODO: or exec() ?
|
||||
$res = $this->getConnection()->query($sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
if ($res === FALSE) {
|
||||
return FALSE;
|
||||
|
||||
if ($res instanceof PDOStatement) {
|
||||
} elseif ($res instanceof PDOStatement) {
|
||||
return new DibiPdoResult($res);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->affectedRows;
|
||||
// not implemented
|
||||
}
|
||||
|
||||
|
||||
|
@@ -23,6 +23,7 @@ if (!class_exists('dibi', FALSE)) die();
|
||||
class DibiPostgreDriver extends DibiDriver
|
||||
{
|
||||
private
|
||||
$insertId = FALSE,
|
||||
$affectedRows = FALSE;
|
||||
|
||||
public
|
||||
@@ -83,7 +84,7 @@ class DibiPostgreDriver extends DibiDriver
|
||||
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
|
||||
$res = @pg_query($this->getConnection(), $sql);
|
||||
|
||||
@@ -91,6 +92,9 @@ class DibiPostgreDriver extends DibiDriver
|
||||
return FALSE;
|
||||
|
||||
} elseif (is_resource($res)) {
|
||||
$this->insertId = pg_last_oid($res);
|
||||
if ($this->insertId < 0) $this->insertId = FALSE;
|
||||
|
||||
$this->affectedRows = pg_affected_rows($res);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
@@ -112,7 +116,7 @@ class DibiPostgreDriver extends DibiDriver
|
||||
|
||||
public function insertId()
|
||||
{
|
||||
return FALSE;
|
||||
return $this->insertId;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,10 +22,6 @@ if (!class_exists('dibi', FALSE)) die();
|
||||
*/
|
||||
class DibiSqliteDriver extends DibiDriver
|
||||
{
|
||||
private
|
||||
$insertId = FALSE,
|
||||
$affectedRows = FALSE;
|
||||
|
||||
public
|
||||
$formats = array(
|
||||
'TRUE' => "1",
|
||||
@@ -81,38 +77,33 @@ class DibiSqliteDriver extends DibiDriver
|
||||
|
||||
public function nativeQuery($sql)
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
$res = @sqlite_query($this->getConnection(), $sql, SQLITE_ASSOC);
|
||||
|
||||
$connection = $this->getConnection();
|
||||
$res = @sqlite_query($connection, $sql, SQLITE_ASSOC);
|
||||
if ($res === FALSE) {
|
||||
return FALSE;
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
$this->affectedRows = sqlite_changes($connection);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = sqlite_last_insert_rowid($connection);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_resource($res)) {
|
||||
} elseif (is_resource($res)) {
|
||||
return new DibiSqliteResult($res);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function affectedRows()
|
||||
{
|
||||
return $this->affectedRows;
|
||||
$rows = sqlite_changes($this->getConnection());
|
||||
return $rows < 0 ? FALSE : $rows;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function insertId()
|
||||
{
|
||||
return $this->insertId;
|
||||
$id = sqlite_last_insert_rowid($this->getConnection());
|
||||
return $id < 1 ? FALSE : $id;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user