diff --git a/phpBB/phpbb/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php index 9b91aa8e0e..2defdf3b3d 100644 --- a/phpBB/phpbb/db/driver/mssql_odbc.php +++ b/phpBB/phpbb/db/driver/mssql_odbc.php @@ -161,7 +161,16 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base if ($this->query_result === false) { - if (($this->query_result = @odbc_exec($this->db_connect_id, $query)) === false) + try + { + $this->query_result = @odbc_exec($this->db_connect_id, $query); + } + catch (\Error $e) + { + // Do nothing as SQL driver will report the error + } + + if ($this->query_result === false) { $this->sql_error($query); } diff --git a/phpBB/phpbb/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php index 8f52e0e39a..9a90a4594c 100644 --- a/phpBB/phpbb/db/driver/mssqlnative.php +++ b/phpBB/phpbb/db/driver/mssqlnative.php @@ -136,12 +136,22 @@ class mssqlnative extends \phpbb\db\driver\mssql_base if ($this->query_result === false) { - if (($this->query_result = @sqlsrv_query($this->db_connect_id, $query, array(), $this->query_options)) === false) + try + { + $this->query_result = @sqlsrv_query($this->db_connect_id, $query, array(), $this->query_options); + } + catch (\Error $e) + { + // Do nothing as SQL driver will report the error + } + + if ($this->query_result === false) { $this->sql_error($query); } - // reset options for next query - $this->query_options = array(); + + // Reset options for the next query + $this->query_options = []; if ($this->debug_sql_explain) { diff --git a/phpBB/phpbb/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php index 38e7f959b1..485bb4dd74 100644 --- a/phpBB/phpbb/db/driver/mysqli.php +++ b/phpBB/phpbb/db/driver/mysqli.php @@ -193,7 +193,16 @@ class mysqli extends \phpbb\db\driver\mysql_base if ($this->query_result === false) { - if (($this->query_result = @mysqli_query($this->db_connect_id, $query)) === false) + try + { + $this->query_result = @mysqli_query($this->db_connect_id, $query); + } + catch (\Error $e) + { + // Do nothing as SQL driver will report the error + } + + if ($this->query_result === false) { $this->sql_error($query); } @@ -332,24 +341,24 @@ class mysqli extends \phpbb\db\driver\mysql_base { if ($this->db_connect_id) { - $error = array( - 'message' => @mysqli_error($this->db_connect_id), - 'code' => @mysqli_errno($this->db_connect_id) - ); + $error = [ + 'message' => $this->db_connect_id->error, + 'code' => $this->db_connect_id->errno, + ]; } else if (function_exists('mysqli_connect_error')) { - $error = array( - 'message' => @mysqli_connect_error(), - 'code' => @mysqli_connect_errno(), - ); + $error = [ + 'message' => $this->db_connect_id->connect_error, + 'code' => $this->db_connect_id->connect_errno, + ]; } else { - $error = array( + $error = [ 'message' => $this->connect_error, 'code' => '', - ); + ]; } return $error; diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php index 17e3681f3a..22bd8132e0 100644 --- a/phpBB/phpbb/db/driver/postgres.php +++ b/phpBB/phpbb/db/driver/postgres.php @@ -183,7 +183,16 @@ class postgres extends \phpbb\db\driver\driver if ($this->query_result === false) { - if (($this->query_result = @pg_query($this->db_connect_id, $query)) === false) + try + { + $this->query_result = @pg_query($this->db_connect_id, $query); + } + catch (\Error $e) + { + // Do nothing as SQL driver will report the error + } + + if ($this->query_result === false) { $this->sql_error($query); } diff --git a/phpBB/phpbb/db/driver/sqlite3.php b/phpBB/phpbb/db/driver/sqlite3.php index 5c03f0b547..b2db70852b 100644 --- a/phpBB/phpbb/db/driver/sqlite3.php +++ b/phpBB/phpbb/db/driver/sqlite3.php @@ -131,7 +131,16 @@ class sqlite3 extends \phpbb\db\driver\driver $query = preg_replace('/^INSERT INTO/', 'INSERT OR ROLLBACK INTO', $query); } - if (($this->query_result = @$this->dbo->query($query)) === false) + try + { + $this->query_result = @$this->dbo->query($query); + } + catch (\Error $e) + { + // Do nothing as SQL driver will report the error + } + + if ($this->query_result === false) { // Try to recover a lost database connection if ($this->dbo && !@$this->dbo->lastErrorMsg()) diff --git a/phpBB/phpbb/db/tools/sqlite3.php b/phpBB/phpbb/db/tools/sqlite3.php new file mode 100644 index 0000000000..1a428b40a8 --- /dev/null +++ b/phpBB/phpbb/db/tools/sqlite3.php @@ -0,0 +1,24 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\tools; + +/** + * Database Tools for handling cross-db actions such as altering columns, etc. + * Currently not supported is returning SQL for creating tables. + * + * @deprecated 4.0.0-a1 + */ +class sqlite3 extends doctrine +{ +}