From 86d2ec40b47f885a6d7e28b9dd519fac3332e7ae Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 17 Feb 2016 19:19:56 +0200 Subject: [ci skip] Update docs to reflect escape_like_str() usage with ESCAPE '\!' Closes #4462 --- user_guide_src/source/database/db_driver_reference.rst | 7 +++++++ user_guide_src/source/database/queries.rst | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/database/db_driver_reference.rst b/user_guide_src/source/database/db_driver_reference.rst index 1e436ede1..1ecd38968 100644 --- a/user_guide_src/source/database/db_driver_reference.rst +++ b/user_guide_src/source/database/db_driver_reference.rst @@ -234,6 +234,13 @@ This article is intended to be a reference for them. and ``_`` wildcard characters, so that they don't cause false-positives in LIKE conditions. + .. important:: The ``escape_like_str()`` method uses '!' (exclamation mark) + to escape special characters for *LIKE* conditions. Because this + method escapes partial strings that you would wrap in quotes + yourself, it cannot automatically add the ``ESCAPE '!'`` + condition for you, and so you'll have to manually do that. + + .. php:method:: primary($table) :param string $table: Table name diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index 43a0a30bf..d4ffd16cf 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -123,7 +123,13 @@ this: $search = '20% raise'; $sql = "SELECT id FROM table WHERE column LIKE '%" . - $this->db->escape_like_str($search)."%'"; + $this->db->escape_like_str($search)."%' ESCAPE '!'"; + +.. important:: The ``escape_like_str()`` method uses '!' (exclamation mark) + to escape special characters for *LIKE* conditions. Because this + method escapes partial strings that you would wrap in quotes + yourself, it cannot automatically add the ``ESCAPE '!'`` + condition for you, and so you'll have to manually do that. ************** -- cgit v1.2.3-24-g4f1b