Commit f28b98cb authored by catch's avatar catch
Browse files

Issue #1182428 by Dave Reid: Fixed Document that db_like() does not work when used with db_query().

parent 9727bd09
...@@ -194,7 +194,7 @@ abstract class DatabaseConnection extends PDO { ...@@ -194,7 +194,7 @@ abstract class DatabaseConnection extends PDO {
/** /**
* The key representing this connection. * The key representing this connection.
* *
* The key is a unique string which identifies a database connection. A * The key is a unique string which identifies a database connection. A
* connection can be a single server or a cluster of master and slaves (use * connection can be a single server or a cluster of master and slaves (use
* target to pick between master and slave). * target to pick between master and slave).
...@@ -2553,13 +2553,18 @@ function db_escape_field($field) { ...@@ -2553,13 +2553,18 @@ function db_escape_field($field) {
* a backslash. Use this to do a search for a verbatim string without any * a backslash. Use this to do a search for a verbatim string without any
* wildcard behavior. * wildcard behavior.
* *
* You must use a query builder like db_select() in order to use db_like() on
* all supported database systems. Using db_like() with db_query() or
* db_query_range() is not supported.
*
* For example, the following does a case-insensitive query for all rows whose * For example, the following does a case-insensitive query for all rows whose
* name starts with $prefix: * name starts with $prefix:
* @code * @code
* $result = db_query( * $result = db_select('person', 'p')
* 'SELECT * FROM person WHERE name LIKE :pattern', * ->fields('p')
* array(':pattern' => db_like($prefix) . '%') * ->condition('name', db_like($prefix) . '%', 'LIKE')
* ); * ->execute()
* ->fetchAll();
* @endcode * @endcode
* *
* Backslash is defined as escape character for LIKE patterns in * Backslash is defined as escape character for LIKE patterns in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment