mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-14 12:44:06 +02:00
[ticket/16955] Clean up code in db classes
PHPBB3-16955
This commit is contained in:
@@ -69,7 +69,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
if ($this->db_connect_id && $this->dbname != '')
|
||||
{
|
||||
// Disable loading local files on client side
|
||||
@mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, false);
|
||||
@mysqli_options($this->db_connect_id, MYSQLI_OPT_LOCAL_INFILE, 0);
|
||||
|
||||
/*
|
||||
* As of PHP 8.1 MySQLi default error mode is set to MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT
|
||||
@@ -143,32 +143,28 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
}
|
||||
}
|
||||
|
||||
return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
|
||||
return ($raw) ? (string) $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Transaction
|
||||
* @access private
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function _sql_transaction($status = 'begin')
|
||||
protected function _sql_transaction(string $status = 'begin'): bool
|
||||
{
|
||||
switch ($status)
|
||||
{
|
||||
case 'begin':
|
||||
return @mysqli_autocommit($this->db_connect_id, false);
|
||||
break;
|
||||
|
||||
case 'commit':
|
||||
$result = @mysqli_commit($this->db_connect_id);
|
||||
@mysqli_autocommit($this->db_connect_id, true);
|
||||
return $result;
|
||||
break;
|
||||
|
||||
case 'rollback':
|
||||
$result = @mysqli_rollback($this->db_connect_id);
|
||||
@mysqli_autocommit($this->db_connect_id, true);
|
||||
return $result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -293,7 +289,7 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
*/
|
||||
function sql_nextid()
|
||||
{
|
||||
return ($this->db_connect_id) ? @mysqli_insert_id($this->db_connect_id) : false;
|
||||
return ($this->db_connect_id) ? (int) @mysqli_insert_id($this->db_connect_id) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,20 +306,12 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
$cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
if (!$query_id)
|
||||
else if ($query_id && $query_id !== true)
|
||||
{
|
||||
return false;
|
||||
mysqli_free_result($query_id);
|
||||
}
|
||||
|
||||
if ($query_id === true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return mysqli_free_result($query_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,10 +323,9 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function _sql_error()
|
||||
protected function _sql_error(): array
|
||||
{
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
@@ -366,19 +353,17 @@ class mysqli extends \phpbb\db\driver\mysql_base
|
||||
}
|
||||
|
||||
/**
|
||||
* Close sql connection
|
||||
* @access private
|
||||
*/
|
||||
function _sql_close()
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function _sql_close(): bool
|
||||
{
|
||||
return @mysqli_close($this->db_connect_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific report
|
||||
* @access private
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function _sql_report($mode, $query = '')
|
||||
protected function _sql_report(string $mode, string $query = ''): void
|
||||
{
|
||||
static $test_prof;
|
||||
|
||||
|
Reference in New Issue
Block a user