From b14a62210355e37382eee2f1c883623db77408a8 Mon Sep 17 00:00:00 2001 From: Neil Drumm Date: Wed, 26 Jul 2006 07:16:08 +0000 Subject: #74997 by dww, add db_table_exists() --- includes/database.mysql.inc | 7 +++++++ includes/database.mysqli.inc | 7 +++++++ includes/database.pgsql.inc | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/includes/database.mysql.inc b/includes/database.mysql.inc index 0326bd508..731107be8 100644 --- a/includes/database.mysql.inc +++ b/includes/database.mysql.inc @@ -364,6 +364,13 @@ function db_unlock_tables() { db_query('UNLOCK TABLES'); } +/** + * Check if a table exists. + */ +function db_table_exists($table) { + return db_num_rows(db_query("SHOW TABLES LIKE '{" . db_escape_table($table) . "}'")); +} + /** * @} End of "ingroup database". */ diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc index a84383357..f15f7cf01 100644 --- a/includes/database.mysqli.inc +++ b/includes/database.mysqli.inc @@ -366,6 +366,13 @@ function db_unlock_tables() { db_query('UNLOCK TABLES'); } +/** + * Check if a table exists. + */ +function db_table_exists($table) { + return db_num_rows(db_query("SHOW TABLES LIKE '{" . db_escape_table($table) . "}'")); +} + /** * @} End of "ingroup database". */ diff --git a/includes/database.pgsql.inc b/includes/database.pgsql.inc index bb7ffd1c0..e969f722a 100644 --- a/includes/database.pgsql.inc +++ b/includes/database.pgsql.inc @@ -343,6 +343,13 @@ function db_unlock_tables() { db_query('COMMIT'); } +/** + * Check if a table exists. + */ +function db_table_exists($table) { + return db_num_rows(db_query("SELECT relname FROM pg_class WHERE relname = '{" . db_escape_table($table) . "}'")); +} + /** * Verify if the database is set up correctly. */ -- cgit v1.2.3