summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/database/query_builder.rst
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-29 23:13:17 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-29 23:13:17 +0100
commit4173823ba1b45955d63cb5e8d60f02312e345bda (patch)
tree96a2cbe539eeebbc895640645005369ea5919712 /user_guide_src/source/database/query_builder.rst
parentcc4b00347c9ff061488bc88194002be701f4190f (diff)
Fix #2041
Diffstat (limited to 'user_guide_src/source/database/query_builder.rst')
-rw-r--r--user_guide_src/source/database/query_builder.rst37
1 files changed, 19 insertions, 18 deletions
diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
index 8fb906052..65609c1cb 100644
--- a/user_guide_src/source/database/query_builder.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -345,23 +345,24 @@ if appropriate
$this->db->like()
=================
-This function enables you to generate **LIKE** clauses, useful for doing
+This method enables you to generate **LIKE** clauses, useful for doing
searches.
-.. note:: All values passed to this function are escaped automatically.
+.. note:: All values passed to this method are escaped automatically.
#. **Simple key/value method:**
::
- $this->db->like('title', 'match'); // Produces: WHERE title LIKE '%match%'
+ $this->db->like('title', 'match');
+ // Produces: WHERE `title` LIKE '%match%' ESCAPE '!'
- If you use multiple function calls they will be chained together with
+ If you use multiple method calls they will be chained together with
AND between them::
$this->db->like('title', 'match');
$this->db->like('body', 'match');
- // WHERE title LIKE '%match%' AND body LIKE '%match%
+ // WHERE `title` LIKE '%match%' ESCAPE '!' AND `body` LIKE '%match% ESCAPE '!'
If you want to control where the wildcard (%) is placed, you can use
an optional third argument. Your options are 'before', 'after' and
@@ -369,9 +370,9 @@ searches.
::
- $this->db->like('title', 'match', 'before'); // Produces: WHERE title LIKE '%match'
- $this->db->like('title', 'match', 'after'); // Produces: WHERE title LIKE 'match%'
- $this->db->like('title', 'match', 'both'); // Produces: WHERE title LIKE '%match%'
+ $this->db->like('title', 'match', 'before'); // Produces: WHERE `title` LIKE '%match' ESCAPE '!'
+ $this->db->like('title', 'match', 'after'); // Produces: WHERE `title` LIKE 'match%' ESCAPE '!'
+ $this->db->like('title', 'match', 'both'); // Produces: WHERE `title` LIKE '%match%' ESCAPE '!'
#. **Associative array method:**
@@ -379,37 +380,37 @@ searches.
$array = array('title' => $match, 'page1' => $match, 'page2' => $match);
$this->db->like($array);
- // WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'
+ // WHERE `title` LIKE '%match%' ESCAPE '!' AND `page1` LIKE '%match%' ESCAPE '!' AND `page2` LIKE '%match%' ESCAPE '!'
$this->db->or_like()
====================
-This function is identical to the one above, except that multiple
+This method is identical to the one above, except that multiple
instances are joined by OR::
$this->db->like('title', 'match'); $this->db->or_like('body', $match);
- // WHERE title LIKE '%match%' OR body LIKE '%match%'
+ // WHERE `title` LIKE '%match%' ESCAPE '!' OR `body` LIKE '%match%' ESCAPE '!'
-.. note:: or_like() was formerly known as orlike(), which has been removed.
+.. note:: ``or_like()`` was formerly known as ``orlike()``, which has been removed.
$this->db->not_like()
=====================
-This function is identical to **like()**, except that it generates NOT
-LIKE statements::
+This method is identical to ``like()``, except that it generates
+NOT LIKE statements::
- $this->db->not_like('title', 'match'); // WHERE title NOT LIKE '%match%
+ $this->db->not_like('title', 'match'); // WHERE `title` NOT LIKE '%match% ESCAPE '!'
$this->db->or_not_like()
========================
-This function is identical to **not_like()**, except that multiple
+This method is identical to ``not_like()``, except that multiple
instances are joined by OR::
$this->db->like('title', 'match');
$this->db->or_not_like('body', 'match');
- // WHERE title LIKE '%match% OR body NOT LIKE '%match%'
+ // WHERE `title` LIKE '%match% OR `body` NOT LIKE '%match%' ESCAPE '!'
$this->db->group_by()
=====================
@@ -1054,4 +1055,4 @@ run the query::
$data = $this->db->get()->result_array();
// Would execute and return an array of results of the following query:
- // SELECT field1, field1 from mytable where field3 = 5;
+ // SELECT field1, field1 from mytable where field3 = 5; \ No newline at end of file