diff --git a/inc/Engine/Common/Database/Queries/AbstractQuery.php b/inc/Engine/Common/Database/Queries/AbstractQuery.php index 992e667eba..e04f0e555d 100644 --- a/inc/Engine/Common/Database/Queries/AbstractQuery.php +++ b/inc/Engine/Common/Database/Queries/AbstractQuery.php @@ -520,8 +520,8 @@ protected function table_exists(): bool { } // Query statement. - $query = 'SELECT table_name FROM information_schema.tables WHERE table_name = %s LIMIT 1'; - $prepared = $db->prepare( $query, $db->{$this->table_name} ); + $query = 'SELECT table_name FROM information_schema.tables WHERE table_schema = %s AND table_name = %s LIMIT 1'; + $prepared = $db->prepare( $query, $db->__get( 'dbname' ), $db->{$this->table_name} ); $result = $db->get_var( $prepared ); // Does the table exist? diff --git a/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php b/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php index 06c5c5e91b..b74e6b2fae 100644 --- a/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php +++ b/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php @@ -125,8 +125,8 @@ protected function table_exists(): bool { } // Query statement. - $query = 'SELECT table_name FROM information_schema.tables WHERE table_name = %s LIMIT 1'; - $prepared = $db->prepare( $query, $db->{$this->table_name} ); + $query = 'SELECT table_name FROM information_schema.tables WHERE table_schema = %s AND table_name = %s LIMIT 1'; + $prepared = $db->prepare( $query, $db->__get( 'dbname' ), $db->{$this->table_name} ); $result = $db->get_var( $prepared ); // Does the table exist?