W3cubDocs

/Drupal 8

public function Schema::getComment

public Schema::getComment($table, $column = NULL)

Retrieve a table or column comment.

File

core/lib/Drupal/Core/Database/Driver/mysql/Schema.php, line 547

Class

Schema
MySQL implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\Core\Database\Driver\mysql

Code

public function getComment($table, $column = NULL) {
  $condition = $this->buildTableNameCondition($table);
  if (isset($column)) {
    $condition->condition('column_name', $column);
    $condition->compile($this->connection, $this);
    // Don't use {} around information_schema.columns table.
    return $this->connection->query("SELECT column_comment FROM information_schema.columns WHERE " . (string) $condition, $condition->arguments())->fetchField();
  }
  $condition->compile($this->connection, $this);
  // Don't use {} around information_schema.tables table.
  $comment = $this->connection->query("SELECT table_comment FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
  // Work-around for MySQL 5.0 bug http://bugs.mysql.com/bug.php?id=11379
  return preg_replace('/; InnoDB free:.*$/', '', $comment);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Driver!mysql!Schema.php/function/Schema::getComment/8.1.x