Skip to content

Commit d996bbc

Browse files
authored
Merge pull request #7152 from kenjis/fix-docs-database/queries.rst
docs: improve database/queries.rst
2 parents 2877ecc + c82a4c7 commit d996bbc

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

user_guide_src/source/database/queries.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,38 @@ fetchable results.
5656
Working with Database Prefixes Manually
5757
***************************************
5858

59+
$db->prefixTable()
60+
==================
61+
5962
If you have configured a database prefix and would like to prepend it to
6063
a table name for use in a native SQL query for example, then you can use
6164
the following:
6265

6366
.. literalinclude:: queries/004.php
6467

68+
$db->setPrefix()
69+
================
70+
6571
If for any reason you would like to change the prefix programmatically
6672
without needing to create a new connection you can use this method:
6773

6874
.. literalinclude:: queries/005.php
6975

76+
$db->getPrefix()
77+
================
78+
7079
You can get the current prefix any time with this method:
7180

7281
.. literalinclude:: queries/006.php
7382

83+
7484
**********************
7585
Protecting Identifiers
7686
**********************
7787

88+
$db->protectIdentifiers()
89+
=========================
90+
7891
In many databases, it is advisable to protect table and field names - for
7992
example with backticks in MySQL. **Query Builder queries are
8093
automatically protected**, but if you need to manually protect an
@@ -93,6 +106,7 @@ prefixing set ``true`` (boolean) via the second parameter:
93106

94107
.. literalinclude:: queries/008.php
95108

109+
96110
***************
97111
Escaping Values
98112
***************
@@ -184,6 +198,7 @@ example:
184198

185199
.. literalinclude:: queries/015.php
186200

201+
187202
****************
188203
Prepared Queries
189204
****************
@@ -257,8 +272,10 @@ hasError()
257272

258273
Returns boolean true/false if the last ``execute()`` call created any errors.
259274

260-
getErrorCode() getErrorMessage()
261-
--------------------------------
275+
getErrorCode()
276+
--------------
277+
getErrorMessage()
278+
-----------------
262279

263280
If any errors were encountered these methods can be used to retrieve the error code and string.
264281

@@ -271,8 +288,8 @@ Internally, all queries are processed and stored as instances of
271288
the parameters, otherwise preparing the query, and storing performance
272289
data about its query.
273290

274-
getLastQuery()
275-
==============
291+
$db->getLastQuery()
292+
===================
276293

277294
When you just need to retrieve the last Query object, use the
278295
``getLastQuery()`` method:
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
22

33
$search = '20% raise';
4-
$sql = "SELECT id FROM table WHERE column LIKE '%" .
5-
$db->escapeLikeString($search) . "%' ESCAPE '!'";
4+
$sql = "SELECT id FROM table WHERE column LIKE '%" . $db->escapeLikeString($search) . "%' ESCAPE '!'";

0 commit comments

Comments
 (0)