Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function DatabaseSchema_pgsql::tableExists

Check if a table exists.

Parameters

$table: The name of the table in drupal (no prefixing).

Return value

TRUE if the given table exists, otherwise FALSE.

Overrides DatabaseSchema::tableExists

6 calls to DatabaseSchema_pgsql::tableExists()
DatabaseSchema_pgsql::addField in includes/database/pgsql/schema.inc
Add a new field to a table.
DatabaseSchema_pgsql::addIndex in includes/database/pgsql/schema.inc
Add an index.
DatabaseSchema_pgsql::addPrimaryKey in includes/database/pgsql/schema.inc
Add a primary key.
DatabaseSchema_pgsql::addUniqueKey in includes/database/pgsql/schema.inc
Add a unique key.
DatabaseSchema_pgsql::dropTable in includes/database/pgsql/schema.inc
Drop a table.

... See full list

File

includes/database/pgsql/schema.inc, line 420

Class

DatabaseSchema_pgsql

Code

public function tableExists($table) {
 // In PostgreSQL "unquoted names are always folded to lower case."
 // @see DatabaseSchema_pgsql::buildTableNameCondition().
 $prefixInfo = $this->getPrefixInfo (strtolower ($table), TRUE);
 return (bool) $this->connection 
 ->query ("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", array(
 ':schema' => $prefixInfo['schema'],
 ':table' => $prefixInfo['table'],
 ))
 ->fetchField ();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.