function Connection::makeComment

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::makeComment()
  2. 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::makeComment()
  3. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::makeComment()

Flatten an array of query comments into a single comment string.

The comment string will be sanitized to avoid SQL injection attacks.

Parameters

string[] $comments: An array of query comment strings.

Return value

string A sanitized comment string.

File

core/lib/Drupal/Core/Database/Connection.php, line 572

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function makeComment($comments) {
    if (empty($comments)) {
        return '';
    }
    // Flatten the array of comments.
    $comment = implode('. ', $comments);
    // Sanitize the comment string so as to avoid SQL injection attacks.
    return '/* ' . $this->filterComment($comment) . ' */ ';
}

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