From e8afa2901340ac8be496bbc3b0013432f92b541c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 28 Mar 2021 11:16:11 +0200 Subject: [PATCH] [ticket/16740] Implement sql_table_exists for psql w/out debug spam Failed pg_query() results in PHP notices now ... PHPBB3-16740 --- phpBB/phpbb/db/tools/postgres.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phpBB/phpbb/db/tools/postgres.php b/phpBB/phpbb/db/tools/postgres.php index 7cb024d4f6..573b40fe5d 100644 --- a/phpBB/phpbb/db/tools/postgres.php +++ b/phpBB/phpbb/db/tools/postgres.php @@ -96,6 +96,24 @@ class postgres extends tools return $tables; } + /** + * {@inheritDoc} + */ + function sql_table_exists($table_name) + { + $sql = "SELECT CAST(EXISTS( + SELECT FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = '" . $this->db->sql_escape($table_name) . "' + ) AS INTEGER)"; + $result = $this->db->sql_query_limit($sql, 1); + $row = $this->db->sql_fetchrow($result); + $table_exists = (booL) $row['exists']; + $this->db->sql_freeresult($result); + + return $table_exists; + } + /** * {@inheritDoc} */