mirror of
https://github.com/friendica/friendica
synced 2025-04-25 13:10:11 +00:00
New function for affected rows
This commit is contained in:
parent
a056afd566
commit
a7526f1291
2 changed files with 25 additions and 12 deletions
|
@ -21,6 +21,8 @@ class dba {
|
|||
private $driver;
|
||||
public $connected = false;
|
||||
public $error = false;
|
||||
public $errorno = 0;
|
||||
public $affected_rows = 0;
|
||||
private $_server_info = '';
|
||||
private static $in_transaction = false;
|
||||
private static $dbo;
|
||||
|
@ -551,6 +553,7 @@ class dba {
|
|||
|
||||
self::$dbo->error = '';
|
||||
self::$dbo->errorno = 0;
|
||||
self::$dbo->affected_rows = 0;
|
||||
|
||||
switch (self::$dbo->driver) {
|
||||
case 'pdo':
|
||||
|
@ -573,6 +576,7 @@ class dba {
|
|||
$retval = false;
|
||||
} else {
|
||||
$retval = $stmt;
|
||||
self::$dbo->affected_rows = $retval->rowCount();
|
||||
}
|
||||
break;
|
||||
case 'mysqli':
|
||||
|
@ -612,6 +616,7 @@ class dba {
|
|||
} else {
|
||||
$stmt->store_result();
|
||||
$retval = $stmt;
|
||||
self::$dbo->affected_rows = $retval->affected_rows;
|
||||
}
|
||||
break;
|
||||
case 'mysql':
|
||||
|
@ -620,6 +625,8 @@ class dba {
|
|||
if (mysql_errno(self::$dbo->db)) {
|
||||
self::$dbo->error = mysql_error(self::$dbo->db);
|
||||
self::$dbo->errorno = mysql_errno(self::$dbo->db);
|
||||
} else {
|
||||
self::$dbo->affected_rows = mysql_affected_rows($retval);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -754,6 +761,15 @@ class dba {
|
|||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of affected rows of the last statement
|
||||
*
|
||||
* @return int Number of rows
|
||||
*/
|
||||
static public function affected_rows() {
|
||||
return self::$dbo->affected_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of rows of a statement
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue