1.20.x database.inc protected DatabaseConnection_mysql::setPrefix($prefix)

}

Overrides DatabaseConnection::setPrefix

File

drivers/database_mysql/database.inc, line 394
Database interface code for MySQL database servers.

Class

DatabaseConnection_mysql

Code

protected function setPrefix($prefix) {
  parent::setPrefix($prefix);
  // Successive versions of MySQL have become increasingly strict about the
  // use of reserved keywords as table names. Drupal 7 uses at least one such
  // table (system). Therefore we surround all table names with quotes.
  $quote_char = MYSQL_IDENTIFIER_QUOTE_CHARACTER_DEFAULT;
  foreach ($this->prefixSearch as $i => $prefixSearch) {
    if (substr($prefixSearch, 0, 1) === '{') {
      // If the prefix already contains one or more quotes remove them.
      // This can happen when - for example - DrupalUnitTestCase sets up a
      // "temporary prefixed database".
      $this->prefixReplace[$i] = $quote_char . str_replace($quote_char, '', $this->prefixReplace[$i]);
    }
    if (substr($prefixSearch, -1) === '}') {
      $this->prefixReplace[$i] .= $quote_char;
    }
  }
}