From ec3290da3b11fd9ff243b77b5de5246478b1325a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 May 2020 18:32:53 +0000 Subject: [PATCH] We already have got a function to check if a table exists --- src/Database/DBA.php | 11 ----------- src/Database/DBStructure.php | 6 +++--- src/Database/Database.php | 12 ------------ 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/Database/DBA.php b/src/Database/DBA.php index f35428718..9825d06c6 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -741,17 +741,6 @@ class DBA return DI::dba()->processlist(); } - /** - * Test if the given table exists - * - * @param string $table - * @return bool - */ - public static function tableExists(string $table) - { - return DI::dba()->tableExists($table); - } - /** * Fetch a database variable * diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index a02d6cf1b..566aea234 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -988,7 +988,7 @@ class DBStructure */ public static function checkInitialValues() { - if (DBA::tableExists('contact') && !DBA::exists('contact', ['id' => 0])) { + if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) { DBA::insert('contact', ['nurl' => '']); $lastid = DBA::lastInsertId(); if ($lastid != 0) { @@ -996,7 +996,7 @@ class DBStructure } } - if (DBA::tableExists('permissionset') && !DBA::exists('permissionset', ['id' => 0])) { + if (self::existsTable('permissionset') && !DBA::exists('permissionset', ['id' => 0])) { DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']); $lastid = DBA::lastInsertId(); if ($lastid != 0) { @@ -1004,7 +1004,7 @@ class DBStructure } } - if (DBA::tableExists('tag') && !DBA::exists('tag', ['id' => 0])) { + if (self::existsTable('tag') && !DBA::exists('tag', ['id' => 0])) { DBA::insert('tag', ['name' => '']); $lastid = DBA::lastInsertId(); if ($lastid != 0) { diff --git a/src/Database/Database.php b/src/Database/Database.php index 97840141a..7adb88ffa 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -1660,18 +1660,6 @@ class Database return (["list" => $statelist, "amount" => $processes]); } - /** - * Test if the given table exists - * - * @param string $table - * @return bool - */ - public function tableExists(string $table) - { - return $this->exists(['information_schema' => 'tables'], - ['table_name' => $table, 'table_schema' => $this->databaseName()]); - } - /** * Fetch a database variable *