columnExists

  1. drupal
    1. drupal7
Versionen
drupal7 public DatabaseSchema::columnExists($table, $column)

Check if a column exists in the given table.

Verwandte Themen

Code

includes/database/schema.inc, line 217

<?php
public function columnExists($table, $column) {
  $condition = $this->buildTableNameCondition($this->connection->prefixTables('{' . $table . '}'));
  $condition->condition('column_name', $column);
  $condition->compile($this->connection);
  // Normally, we would heartily discourage the use of string
  // concatination for conditionals like this however, we
  // couldn't use db_select() here because it would prefix
  // information_schema.tables and the query would fail.
  // Don't use {} around information_schema table.
  return db_query("SELECT column_name FROM information_schema.columns WHERE " . (string) $condition, $condition->arguments())->fetchAllKeyed(0, 0);
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen