1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-08 09:46:46 +02:00

Merge branch 'develop-ascraeus' into develop

* develop-ascraeus:
  [ticket/12570] Keep MySQLi procedural
  [ticket/12570] Remove test for affected rows after SELECT
  [ticket/12570] Add a test for set_array() and updating with the same value
  [ticket/12570] Fix MySQL affectedrows
  [ticket/12570] Fix MySQLi affectedrows by specifying MYSQLI_CLIENT_FOUND_ROWS
  [ticket/12570] Add a unit test to show broken sql_affectedrows()
  [ticket/12570] Add test for updating a config with the same value
This commit is contained in:
Andreas Fischer
2014-05-26 23:09:51 +02:00
4 changed files with 96 additions and 4 deletions

View File

@@ -207,7 +207,26 @@ class mysql extends \phpbb\db\driver\mysql_base
*/
function sql_affectedrows()
{
return ($this->db_connect_id) ? @mysql_affected_rows($this->db_connect_id) : false;
if ($this->db_connect_id)
{
// We always want the number of matched rows
// instead of changed rows, when running an update.
// So when mysql_info() returns the number of matched rows
// we return that one instead of mysql_affected_rows()
$mysql_info = @mysql_info($this->db_connect_id);
if ($mysql_info !== false)
{
$match = array();
preg_match('#^Rows matched: (\d)+ Changed: (\d)+ Warnings: (\d)+$#', $mysql_info, $match);
if (isset($match[1]))
{
return $match[1];
}
}
return @mysql_affected_rows($this->db_connect_id);
}
return false;
}
/**

View File

@@ -57,7 +57,8 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
}
$this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket);
$this->db_connect_id = mysqli_init();
@mysqli_real_connect($this->db_connect_id, $this->server, $this->user, $sqlpassword, $this->dbname, $port, $socket, MYSQLI_CLIENT_FOUND_ROWS);
if ($this->db_connect_id && $this->dbname != '')
{