public function DatabaseConnection::escapeLike

cis7 database.inc public DatabaseConnection::escapeLike($string)
cle7 database.inc public DatabaseConnection::escapeLike($string)
elmsmedia7 database.inc public DatabaseConnection::escapeLike($string)
icor7 database.inc public DatabaseConnection::escapeLike($string)
meedjum_blog7 database.inc public DatabaseConnection::escapeLike($string)
mooc7 database.inc public DatabaseConnection::escapeLike($string)

Escapes characters that work as wildcard characters in a LIKE pattern.

The wildcard characters "%" and "_" as well as backslash are prefixed with a backslash. Use this to do a search for a verbatim string without any wildcard behavior.

For example, the following does a case-insensitive query for all rows whose name starts with $prefix:

$result = db_query(
  'SELECT * FROM person WHERE name LIKE :pattern',
  array(':pattern' => db_like($prefix) . '%')
);

Backslash is defined as escape character for LIKE patterns in DatabaseCondition::mapConditionOperator().

Parameters

$string: The string to escape.

Return value

The escaped string.

File

includes/database/database.inc, line 980
Core systems for the database layer.

Class

DatabaseConnection
Base Database API class.

Code

public function escapeLike($string) {
  return addcslashes($string, '\%_');
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.