diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/database.mysql.inc | 7 | ||||
-rw-r--r-- | includes/database.mysqli.inc | 7 | ||||
-rw-r--r-- | includes/database.pgsql.inc | 7 |
3 files changed, 21 insertions, 0 deletions
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 @@ -365,6 +365,13 @@ function db_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 @@ -367,6 +367,13 @@ function db_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 @@ -344,6 +344,13 @@ function db_unlock_tables() { } /** + * 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. */ function db_check_setup() { |