mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
- affectedRows(), insertId(), rowCount() are aliases for getAffectedRows(), getInsertId(), getRowCount()
This commit is contained in:
@@ -370,27 +370,52 @@ class dibi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of affected rows.
|
* Gets the number of affected rows.
|
||||||
* Monostate for DibiConnection::affectedRows()
|
* Monostate for DibiConnection::getAffectedRows()
|
||||||
|
* @return int number of rows
|
||||||
|
* @throws DibiException
|
||||||
|
*/
|
||||||
|
public static function getAffectedRows()
|
||||||
|
{
|
||||||
|
return self::getConnection()->getAffectedRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of affected rows. Alias for getAffectedRows().
|
||||||
* @return int number of rows
|
* @return int number of rows
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public static function affectedRows()
|
public static function affectedRows()
|
||||||
{
|
{
|
||||||
return self::getConnection()->affectedRows();
|
return self::getConnection()->getAffectedRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* Monostate for DibiConnection::insertId()
|
* Monostate for DibiConnection::getInsertId()
|
||||||
|
* @param string optional sequence name
|
||||||
|
* @return int
|
||||||
|
* @throws DibiException
|
||||||
|
*/
|
||||||
|
public static function getInsertId($sequence=NULL)
|
||||||
|
{
|
||||||
|
return self::getConnection()->getInsertId($sequence);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
|
||||||
* @param string optional sequence name
|
* @param string optional sequence name
|
||||||
* @return int
|
* @return int
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public static function insertId($sequence=NULL)
|
public static function insertId($sequence=NULL)
|
||||||
{
|
{
|
||||||
return self::getConnection()->insertId($sequence);
|
return self::getConnection()->getInsertId($sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return mssql_rows_affected($this->connection);
|
return mssql_rows_affected($this->connection);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
$res = mssql_query('SELECT @@IDENTITY', $this->connection);
|
$res = mssql_query('SELECT @@IDENTITY', $this->connection);
|
||||||
if (is_resource($res)) {
|
if (is_resource($res)) {
|
||||||
@@ -276,7 +276,7 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
return mssql_num_rows($this->resultSet);
|
return mssql_num_rows($this->resultSet);
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,6 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Moves cursor position without fetching row.
|
* Moves cursor position without fetching row.
|
||||||
* @param int the 0-based cursor pos to seek to
|
* @param int the 0-based cursor pos to seek to
|
||||||
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
||||||
* @throws DibiException
|
|
||||||
*/
|
*/
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
|
@@ -121,7 +121,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return sqlsrv_rows_affected($this->resultSet);
|
return sqlsrv_rows_affected($this->resultSet);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
$res = sqlsrv_query($this->connection, 'SELECT @@IDENTITY');
|
$res = sqlsrv_query($this->connection, 'SELECT @@IDENTITY');
|
||||||
if (is_resource($res)) {
|
if (is_resource($res)) {
|
||||||
@@ -276,9 +276,9 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
throw new NotSupportedException('Row count is not available for unbuffered queries.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -306,11 +306,10 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
|||||||
* Moves cursor position without fetching row.
|
* Moves cursor position without fetching row.
|
||||||
* @param int the 0-based cursor pos to seek to
|
* @param int the 0-based cursor pos to seek to
|
||||||
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
||||||
* @throws DibiException
|
|
||||||
*/
|
*/
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
throw new DibiDriverException('Cannot seek an unbuffered result set.');
|
throw new NotSupportedException('Cannot seek an unbuffered result set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -198,7 +198,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return mysql_affected_rows($this->connection);
|
return mysql_affected_rows($this->connection);
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
return mysql_insert_id($this->connection);
|
return mysql_insert_id($this->connection);
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
if (!$this->buffered) {
|
if (!$this->buffered) {
|
||||||
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
||||||
|
@@ -182,7 +182,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return mysqli_affected_rows($this->connection);
|
return mysqli_affected_rows($this->connection);
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
return mysqli_insert_id($this->connection);
|
return mysqli_insert_id($this->connection);
|
||||||
}
|
}
|
||||||
@@ -328,7 +328,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
if (!$this->buffered) {
|
if (!$this->buffered) {
|
||||||
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
||||||
|
@@ -125,7 +125,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return odbc_num_rows($this->resultSet);
|
return odbc_num_rows($this->resultSet);
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException('ODBC does not support autoincrementing.');
|
throw new NotSupportedException('ODBC does not support autoincrementing.');
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
// will return -1 with many drivers :-(
|
// will return -1 with many drivers :-(
|
||||||
return odbc_num_rows($this->resultSet);
|
return odbc_num_rows($this->resultSet);
|
||||||
@@ -314,7 +314,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
|||||||
* Moves cursor position without fetching row.
|
* Moves cursor position without fetching row.
|
||||||
* @param int the 0-based cursor pos to seek to
|
* @param int the 0-based cursor pos to seek to
|
||||||
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
||||||
* @throws DibiException
|
|
||||||
*/
|
*/
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
|
@@ -126,7 +126,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException('Oracle does not support autoincrementing.');
|
throw new NotSupportedException('Oracle does not support autoincrementing.');
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
|
|||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optinal savepoint name
|
* @param string optinal savepoint name
|
||||||
* @return void
|
* @return void
|
||||||
* @throws DibiDriverException
|
|
||||||
*/
|
*/
|
||||||
public function begin($savepoint = NULL)
|
public function begin($savepoint = NULL)
|
||||||
{
|
{
|
||||||
@@ -278,9 +277,9 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
throw new NotSupportedException('Row count is not available for unbuffered queries.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -302,7 +301,6 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
|
|||||||
* Moves cursor position without fetching row.
|
* Moves cursor position without fetching row.
|
||||||
* @param int the 0-based cursor pos to seek to
|
* @param int the 0-based cursor pos to seek to
|
||||||
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
||||||
* @throws DibiException
|
|
||||||
*/
|
*/
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
|
@@ -142,7 +142,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return $this->affectedRows;
|
return $this->affectedRows;
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
return $this->connection->lastInsertId();
|
return $this->connection->lastInsertId();
|
||||||
}
|
}
|
||||||
@@ -347,9 +347,9 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
throw new NotSupportedException('Row count is not available for unbuffered queries.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -371,11 +371,10 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
|
|||||||
* Moves cursor position without fetching row.
|
* Moves cursor position without fetching row.
|
||||||
* @param int the 0-based cursor pos to seek to
|
* @param int the 0-based cursor pos to seek to
|
||||||
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
||||||
* @throws DibiException
|
|
||||||
*/
|
*/
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
throw new DibiDriverException('Cannot seek an unbuffered result set.');
|
throw new NotSupportedException('Cannot seek an unbuffered result set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -147,7 +147,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return pg_affected_rows($this->resultSet);
|
return pg_affected_rows($this->resultSet);
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
if ($sequence === NULL) {
|
if ($sequence === NULL) {
|
||||||
// PostgreSQL 8.1 is needed
|
// PostgreSQL 8.1 is needed
|
||||||
@@ -326,7 +326,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
return pg_num_rows($this->resultSet);
|
return pg_num_rows($this->resultSet);
|
||||||
}
|
}
|
||||||
@@ -350,7 +350,6 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
|||||||
* Moves cursor position without fetching row.
|
* Moves cursor position without fetching row.
|
||||||
* @param int the 0-based cursor pos to seek to
|
* @param int the 0-based cursor pos to seek to
|
||||||
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
* @return boolean TRUE on success, FALSE if unable to seek to specified record
|
||||||
* @throws DibiException
|
|
||||||
*/
|
*/
|
||||||
public function seek($row)
|
public function seek($row)
|
||||||
{
|
{
|
||||||
@@ -417,7 +416,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
|||||||
{
|
{
|
||||||
$version = pg_version($this->connection);
|
$version = pg_version($this->connection);
|
||||||
if ($version['server'] < 8) {
|
if ($version['server'] < 8) {
|
||||||
throw new NotSupportedException('Reflection requires PostgreSQL 8.');
|
throw new DibiDriverException('Reflection requires PostgreSQL 8.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->query("
|
$this->query("
|
||||||
|
@@ -145,7 +145,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
return sqlite_changes($this->connection);
|
return sqlite_changes($this->connection);
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence)
|
public function getInsertId($sequence)
|
||||||
{
|
{
|
||||||
return sqlite_last_insert_rowid($this->connection);
|
return sqlite_last_insert_rowid($this->connection);
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function rowCount()
|
public function getRowCount()
|
||||||
{
|
{
|
||||||
if (!$this->buffered) {
|
if (!$this->buffered) {
|
||||||
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
throw new DibiDriverException('Row count is not available for unbuffered queries.');
|
||||||
|
@@ -338,7 +338,7 @@ class DibiConnection extends DibiObject
|
|||||||
if ($res = $this->driver->query($sql)) { // intentionally =
|
if ($res = $this->driver->query($sql)) { // intentionally =
|
||||||
$res = new DibiResult($res, $this->config);
|
$res = new DibiResult($res, $this->config);
|
||||||
} else {
|
} else {
|
||||||
$res = $this->driver->affectedRows();
|
$res = $this->driver->getAffectedRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
$time += microtime(TRUE);
|
$time += microtime(TRUE);
|
||||||
@@ -358,30 +358,55 @@ class DibiConnection extends DibiObject
|
|||||||
* @return int number of rows
|
* @return int number of rows
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function affectedRows()
|
public function getAffectedRows()
|
||||||
{
|
{
|
||||||
$rows = $this->driver->affectedRows();
|
$rows = $this->driver->getAffectedRows();
|
||||||
if (!is_int($rows) || $rows < 0) throw new DibiException('Cannot retrieve number of affected rows.');
|
if (!is_int($rows) || $rows < 0) throw new DibiException('Cannot retrieve number of affected rows.');
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of affected rows. Alias for getAffectedRows().
|
||||||
|
* @return int number of rows
|
||||||
|
* @throws DibiException
|
||||||
|
*/
|
||||||
|
public function affectedRows()
|
||||||
|
{
|
||||||
|
return $this->getAffectedRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @param string optional sequence name
|
* @param string optional sequence name
|
||||||
* @return int
|
* @return int
|
||||||
* @throws DibiException
|
* @throws DibiException
|
||||||
*/
|
*/
|
||||||
public function insertId($sequence = NULL)
|
public function getInsertId($sequence = NULL)
|
||||||
{
|
{
|
||||||
$id = $this->driver->insertId($sequence);
|
$id = $this->driver->getInsertId($sequence);
|
||||||
if ($id < 1) throw new DibiException('Cannot retrieve last generated ID.');
|
if ($id < 1) throw new DibiException('Cannot retrieve last generated ID.');
|
||||||
return (int) $id;
|
return (int) $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
|
||||||
|
* @param string optional sequence name
|
||||||
|
* @return int
|
||||||
|
* @throws DibiException
|
||||||
|
*/
|
||||||
|
public function insertId($sequence = NULL)
|
||||||
|
{
|
||||||
|
return $this->getInsertId($sequence);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a transaction (if supported).
|
* Begins a transaction (if supported).
|
||||||
* @param string optinal savepoint name
|
* @param string optinal savepoint name
|
||||||
|
@@ -262,7 +262,7 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
public function execute($return = NULL)
|
public function execute($return = NULL)
|
||||||
{
|
{
|
||||||
$res = $this->connection->query($this->_export());
|
$res = $this->connection->query($this->_export());
|
||||||
return $return === dibi::IDENTIFIER ? $this->connection->insertId() : $res;
|
return $return === dibi::IDENTIFIER ? $this->connection->getInsertId() : $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -116,9 +116,20 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
final public function getRowCount()
|
||||||
|
{
|
||||||
|
return $this->getDriver()->getRowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of rows in a result set. Alias for getRowCount().
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
final public function rowCount()
|
final public function rowCount()
|
||||||
{
|
{
|
||||||
return $this->getDriver()->rowCount();
|
return $this->getDriver()->getRowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -602,7 +613,7 @@ class DibiResult extends DibiObject implements IDataSource
|
|||||||
*/
|
*/
|
||||||
final public function count()
|
final public function count()
|
||||||
{
|
{
|
||||||
return $this->rowCount();
|
return $this->getRowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -147,7 +147,7 @@ interface IDibiDriver
|
|||||||
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
* Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
|
||||||
* @return int|FALSE number of rows or FALSE on error
|
* @return int|FALSE number of rows or FALSE on error
|
||||||
*/
|
*/
|
||||||
function affectedRows();
|
function getAffectedRows();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ interface IDibiDriver
|
|||||||
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
* Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
|
||||||
* @return int|FALSE int on success or FALSE on failure
|
* @return int|FALSE int on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
function insertId($sequence);
|
function getInsertId($sequence);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ interface IDibiDriver
|
|||||||
* Returns the number of rows in a result set.
|
* Returns the number of rows in a result set.
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function rowCount();
|
function getRowCount();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user