mirror of
https://github.com/dg/dibi.git
synced 2025-08-13 01:24:06 +02:00
- affectedRows(), insertId(), rowCount() are aliases for getAffectedRows(), getInsertId(), getRowCount()
This commit is contained in:
@@ -338,7 +338,7 @@ class DibiConnection extends DibiObject
|
||||
if ($res = $this->driver->query($sql)) { // intentionally =
|
||||
$res = new DibiResult($res, $this->config);
|
||||
} else {
|
||||
$res = $this->driver->affectedRows();
|
||||
$res = $this->driver->getAffectedRows();
|
||||
}
|
||||
|
||||
$time += microtime(TRUE);
|
||||
@@ -358,30 +358,55 @@ class DibiConnection extends DibiObject
|
||||
* @return int number of rows
|
||||
* @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.');
|
||||
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.
|
||||
* @param string optional sequence name
|
||||
* @return int
|
||||
* @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.');
|
||||
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).
|
||||
* @param string optinal savepoint name
|
||||
|
@@ -262,7 +262,7 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
public function execute($return = NULL)
|
||||
{
|
||||
$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.
|
||||
* @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()
|
||||
{
|
||||
return $this->getDriver()->rowCount();
|
||||
return $this->getDriver()->getRowCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -602,7 +613,7 @@ class DibiResult extends DibiObject implements IDataSource
|
||||
*/
|
||||
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.
|
||||
* @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.
|
||||
* @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.
|
||||
* @return int
|
||||
*/
|
||||
function rowCount();
|
||||
function getRowCount();
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user