Same name in this branch
  1. 6.x includes/database.pgsql.inc \db_table_exists()
  2. 6.x includes/database.mysqli.inc \db_table_exists()
  3. 6.x includes/database.mysql.inc \db_table_exists()
Same name and namespace in other branches
  1. 5.x includes/database.pgsql.inc \db_table_exists()
  2. 5.x includes/database.mysqli.inc \db_table_exists()
  3. 5.x includes/database.mysql.inc \db_table_exists()
  4. 7.x includes/database/database.inc \db_table_exists()
  5. 8.9.x core/includes/database.inc \db_table_exists()

Check if a table exists.

Parameters

$table: The name of the table.

Return value

TRUE if the table exists, and FALSE if the table does not exist.

Related topics

12 calls to db_table_exists()
blogapi_update_6001 in modules/blogapi/blogapi.install
Add blogapi_files table to enable size restriction for BlogAPI file uploads.
system_update_6019 in modules/system/system.install
Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.
system_update_6030 in modules/system/system.install
Add the tables required by actions.inc.
system_update_6032 in modules/system/system.install
profile_fields.name used to be nullable but is part of a unique key and so shouldn't be.
system_update_6033 in modules/system/system.install
Change node_comment_statistics to be not autoincrement.

... See full list

File

includes/database.mysql.inc, line 355
Database interface code for MySQL database servers.

Code

function db_table_exists($table) {
  return (bool) db_fetch_object(db_query("SHOW TABLES LIKE '{" . db_escape_table($table) . "}'"));
}