You are here

function privatemsg_db_index_exists in Privatemsg 6.2

Checks if an index exists in the given table.

Parameters

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

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

Return value

TRUE if the given index exists, otherwise FALSE.

3 calls to privatemsg_db_index_exists()
privatemsg_filter_update_6202 in privatemsg_filter/privatemsg_filter.install
Add new indexes to existing 6.x-2.x installations.
privatemsg_update_6203 in ./privatemsg.install
Add primary key to {pm_index}.
privatemsg_update_6204 in ./privatemsg.install
Update indexes for 6.x-2.x instances.

File

./privatemsg.install, line 760
Install file for privatemsg.module

Code

function privatemsg_db_index_exists($table, $name) {
  global $db_type;
  if ($db_type == 'pgsql') {
    $index_name = '{' . $table . '}_' . $name . '_idx';
    return (bool) db_result(db_query("SELECT 1 FROM pg_indexes WHERE indexname = '{$index_name}'"));
  }
  else {
    return (bool) db_fetch_array(db_query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '{$name}'"));
  }
}