mirror of
https://github.com/dg/dibi.git
synced 2025-08-16 11:04:43 +02:00
* fixed affectedRows & insertId bug
This commit is contained in:
@@ -84,7 +84,7 @@ class DibiMySqlDriver extends DibiDriver {
|
||||
|
||||
|
||||
if (!empty($config['charset'])) {
|
||||
$succ = @mysql_query("SET NAMES '" . $config['charset'] . "'", $conn);
|
||||
@mysql_query("SET NAMES '" . $config['charset'] . "'", $conn);
|
||||
// don't handle this error...
|
||||
}
|
||||
|
||||
@@ -112,15 +112,15 @@ class DibiMySqlDriver extends DibiDriver {
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiMySqlResult($res);
|
||||
|
||||
$this->affectedRows = mysql_affected_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = mysql_insert_id($this->conn);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiMySqlResult($res);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -80,15 +80,15 @@ class DibiMySqliDriver extends DibiDriver {
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_object($res))
|
||||
return new DibiMySqliResult($res);
|
||||
|
||||
$this->affectedRows = mysqli_affected_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = mysqli_insert_id($this->conn);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_object($res))
|
||||
return new DibiMySqliResult($res);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -84,12 +84,12 @@ class DibiOdbcDriver extends DibiDriver {
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiOdbcResult($res);
|
||||
|
||||
$this->affectedRows = odbc_num_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiOdbcResult($res);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -167,6 +167,8 @@ class DibiOdbcDriver extends DibiDriver {
|
||||
// offset suppot is missing...
|
||||
if ($limit >= 0)
|
||||
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
|
||||
|
||||
if ($offset) throw new DibiException('Offset is not implemented.');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -49,7 +49,6 @@ class DibiPostgreDriver extends DibiDriver {
|
||||
|
||||
if (empty($config['type'])) $config['type'] = NULL;
|
||||
|
||||
$errorMsg = '';
|
||||
if (isset($config['persistent']))
|
||||
$conn = @pg_connect($config['string'], $config['type']);
|
||||
else
|
||||
@@ -61,7 +60,7 @@ class DibiPostgreDriver extends DibiDriver {
|
||||
));
|
||||
|
||||
if (!empty($config['charset'])) {
|
||||
$succ = @pg_set_client_encoding($conn, $config['charset']);
|
||||
@pg_set_client_encoding($conn, $config['charset']);
|
||||
// don't handle this error...
|
||||
}
|
||||
|
||||
@@ -76,17 +75,16 @@ class DibiPostgreDriver extends DibiDriver {
|
||||
{
|
||||
$this->affectedRows = FALSE;
|
||||
|
||||
$errorMsg = '';
|
||||
$res = @pg_query($this->conn, $sql);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiPostgreResult($res);
|
||||
|
||||
$this->affectedRows = pg_affected_rows($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiPostgreResult($res);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -74,20 +74,20 @@ class DibiSqliteDriver extends DibiDriver {
|
||||
{
|
||||
$this->insertId = $this->affectedRows = FALSE;
|
||||
|
||||
$errorMsg = '';
|
||||
$this->errorMsg = '';
|
||||
$res = @sqlite_query($this->conn, $sql, SQLITE_ASSOC, $this->errorMsg);
|
||||
|
||||
if ($res === FALSE) return FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiSqliteResult($res);
|
||||
|
||||
$this->affectedRows = sqlite_changes($this->conn);
|
||||
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
|
||||
|
||||
$this->insertId = sqlite_last_insert_rowid($this->conn);
|
||||
if ($this->insertId < 1) $this->insertId = FALSE;
|
||||
|
||||
if (is_resource($res))
|
||||
return new DibiSqliteResult($res);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user