public static function Connection::sqlFunctionLikeBinary

public static Connection::sqlFunctionLikeBinary($pattern, $subject)

SQLite compatibility implementation for the LIKE BINARY SQL operator.

SQLite supports case-sensitive LIKE operations through the 'case_sensitive_like' PRAGMA statement, but only for ASCII characters, so we have to provide our own implementation with UTF-8 support.

See also

https://sqlite.org/pragma.html#pragma_case_sensitive_like

https://sqlite.org/lang_expr.html#like

File

core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php, line 290

Class

Connection
SQLite implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\Core\Database\Driver\sqlite

Code

public static function sqlFunctionLikeBinary($pattern, $subject) {
  // Replace the SQL LIKE wildcard meta-characters with the equivalent regular
  // expression meta-characters and escape the delimiter that will be used for
  // matching.
  $pattern = str_replace(array('%', '_'), array('.*?', '.'), preg_quote($pattern, '/'));
  return preg_match('/^' . $pattern . '$/', $subject);
}

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