public function Schema::prepareComment

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::prepareComment()
  2. 9.x drupal/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::prepareComment()

Prepare a table or column comment for database query.

Parameters

$comment: The comment string to prepare.

$length: Optional upper limit on the returned string length.

Return value

The prepared comment.

Overrides Schema::prepareComment

2 calls to Schema::prepareComment()
Schema::createFieldSql in drupal/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
Create an SQL string for a field to be used in table creation or alteration.
Schema::createTableSql in drupal/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php
Generate SQL to create a new table from a Drupal schema definition.

File

drupal/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php, line 476
Definition of Drupal\Core\Database\Driver\mysql\Schema

Class

Schema

Namespace

Drupal\Core\Database\Driver\mysql

Code

public function prepareComment($comment, $length = NULL) {

  // Work around a bug in some versions of PDO, see http://bugs.php.net/bug.php?id=41125
  $comment = str_replace("'", '’', $comment);

  // Truncate comment to maximum comment length.
  if (isset($length)) {

    // Add table prefixes before truncating.
    $comment = truncate_utf8($this->connection
      ->prefixTables($comment), $length, TRUE, TRUE);
  }
  return $this->connection
    ->quote($comment);
}