1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-14 01:54:08 +02:00

update to 0.5b

This commit is contained in:
David Grudl
2006-06-04 23:09:53 +00:00
parent 0d18c4c366
commit 8e166989d6
12 changed files with 62 additions and 35 deletions

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/
@@ -26,7 +26,9 @@ if (!defined('dibi')) die();
*/
class DibiMySqlDriver extends DibiDriver {
private
$conn;
$conn,
$insertId = FALSE,
$affectedRows = FALSE;
public
$formats = array(
@@ -100,6 +102,7 @@ class DibiMySqlDriver extends DibiDriver {
public function query($sql)
{
$this->insertId = $this->affectedRows = FALSE;
$res = @mysql_query($sql, $this->conn);
if (is_resource($res))
@@ -112,21 +115,25 @@ class DibiMySqlDriver extends DibiDriver {
'sql' => $sql,
));
$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;
return TRUE;
}
public function affectedRows()
{
$rows = mysql_affected_rows($this->conn);
return $rows < 0 ? FALSE : $rows;
return $this->affectedRows;
}
public function insertId()
{
$id = mysql_insert_id($this->conn);
return $id < 0 ? FALSE : $id;
return $this->insertId;
}

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/
@@ -26,7 +26,9 @@ if (!defined('dibi')) die();
*/
class DibiMySqliDriver extends DibiDriver {
private
$conn;
$conn,
$insertId = FALSE,
$affectedRows = FALSE;
public
$formats = array(
@@ -66,6 +68,7 @@ class DibiMySqliDriver extends DibiDriver {
public function query($sql)
{
$this->insertId = $this->affectedRows = FALSE;
$res = @mysqli_query($this->conn, $sql);
if (is_object($res))
@@ -74,21 +77,25 @@ class DibiMySqliDriver extends DibiDriver {
if ($res === FALSE)
return new DibiException("Query error", $this->errorInfo($sql));
$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;
return TRUE;
}
public function affectedRows()
{
$rows = mysqli_affected_rows($this->conn);
return $rows < 0 ? FALSE : $rows;
return $this->affectedRows;
}
public function insertId()
{
$id = mysqli_insert_id($this->conn);
return $id < 1 ? FALSE : $id;
return $this->insertId;
}

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/
@@ -26,7 +26,8 @@ if (!defined('dibi')) die();
*/
class DibiOdbcDriver extends DibiDriver {
private
$conn;
$conn,
$affectedRows = FALSE;
public
$formats = array(
@@ -64,6 +65,8 @@ class DibiOdbcDriver extends DibiDriver {
public function query($sql)
{
$this->affectedRows = FALSE;
$res = @odbc_exec($this->conn, $sql);
if (is_resource($res))
@@ -72,14 +75,16 @@ class DibiOdbcDriver extends DibiDriver {
if ($res === FALSE)
return new DibiException("Query error", $this->errorInfo($sql));
$this->affectedRows = odbc_num_rows($this->conn);
if ($this->affectedRows < 0) $this->affectedRows = FALSE;
return TRUE;
}
public function affectedRows()
{
$rows = odbc_num_rows($this->conn);
return $rows < 0 ? FALSE : $rows;
return $this->affectedRows;
}

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/
@@ -26,7 +26,9 @@ if (!defined('dibi')) die();
*/
class DibiSqliteDriver extends DibiDriver {
private
$conn;
$conn,
$insertId = FALSE,
$affectedRows = FALSE;
public
$formats = array(
@@ -67,6 +69,8 @@ class DibiSqliteDriver extends DibiDriver {
public function query($sql)
{
$this->insertId = $this->affectedRows = FALSE;
$errorMsg = '';
$res = @sqlite_query($this->conn, $sql, SQLITE_ASSOC, $errorMsg);
@@ -79,21 +83,25 @@ class DibiSqliteDriver extends DibiDriver {
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;
return TRUE;
}
public function affectedRows()
{
$rows = sqlite_changes($this->conn);
return $rows < 0 ? FALSE : $rows;
return $this->affectedRows;
}
public function insertId()
{
$id = sqlite_last_insert_rowid($this->conn);
return $id < 1 ? FALSE : $id;
return $this->insertId;
}

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/

View File

@@ -12,7 +12,7 @@
* @license GNU GENERAL PUBLIC LICENSE
* @package dibi
* @category Database
* @version 0.5alpha (2006-05-26) for PHP5
* @version 0.5b (2006-05-31) for PHP5
*/
@@ -350,7 +350,7 @@ class DibiResultIterator implements Iterator
{
$this->result = $result;
$this->offset = (int) $offset;
$this->count = $count === NULL ? PHP_INT_MAX : (int) $count;
$this->count = $count === NULL ? 2147483647 /*PHP_INT_MAX till 5.0.5 */ : (int) $count;
}