Skip to content
Snippets Groups Projects
Commit b14a6221 authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

#74997 by dww, add db_table_exists()

parent cfaa4b5f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -364,6 +364,13 @@ function db_unlock_tables() { ...@@ -364,6 +364,13 @@ function db_unlock_tables() {
db_query('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". * @} End of "ingroup database".
*/ */
......
...@@ -366,6 +366,13 @@ function db_unlock_tables() { ...@@ -366,6 +366,13 @@ function db_unlock_tables() {
db_query('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". * @} End of "ingroup database".
*/ */
......
...@@ -343,6 +343,13 @@ function db_unlock_tables() { ...@@ -343,6 +343,13 @@ function db_unlock_tables() {
db_query('COMMIT'); 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. * Verify if the database is set up correctly.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment