W3cubDocs

/Drupal 8

public function Connection::makeComment

public Connection::makeComment($comments)

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 491

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) . ' */ ';
}

© 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!Connection.php/function/Connection::makeComment/8.1.x