1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-16 21:54:00 +02:00

[ticket/17232] Improve SQL error messages handling

PHP 7 changes how most errors are reported by PHP. Instead of reporting errors
through the traditional error reporting mechanism used by PHP 5, most errors
are now reported by throwing Error exceptions.
Use it to display meaningful SQL error messages instead of PHP fatal errors
for SQL errors.

PHPBB3-17232
This commit is contained in:
rxu
2023-12-20 11:45:58 +07:00
parent 213d092f6f
commit 6a8140e82b
7 changed files with 106 additions and 17 deletions

View File

@@ -0,0 +1,39 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @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.
*/
class sqlite3 extends tools
{
/**
* {@inheritDoc}
*/
function sql_table_exists($table_name)
{
$this->db->sql_return_on_error(true);
$result = $this->db->sql_query("SELECT name FROM sqlite_master WHERE type='table' AND name='{$table_name}'");
$this->db->sql_return_on_error(false);
if (!empty($this->db->sql_fetchrowset($result)))
{
$this->db->sql_freeresult($result);
return true;
}
return false;
}
}