Skip to content

Commit 9b092ff

Browse files
committed
docs: make method names linkable
1 parent 3ad9f67 commit 9b092ff

1 file changed

Lines changed: 43 additions & 22 deletions

File tree

user_guide_src/source/database/queries.rst

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,30 @@ It's a very good security practice to escape your data before submitting
9999
it into your database. CodeIgniter has three methods that help you do
100100
this:
101101

102-
#. **$db->escape()** This function determines the data type so
103-
that it can escape only string data. It also automatically adds
104-
single quotes around the data so you don't have to:
102+
1. $db->escape()
103+
================
105104

106-
.. literalinclude:: queries/009.php
105+
This function determines the data type so
106+
that it can escape only string data. It also automatically adds
107+
single quotes around the data so you don't have to:
107108

108-
#. **$db->escapeString()** This function escapes the data passed to
109-
it, regardless of type. Most of the time you'll use the above
110-
function rather than this one. Use the function like this:
109+
.. literalinclude:: queries/009.php
111110

112-
.. literalinclude:: queries/010.php
111+
2. $db->escapeString()
112+
======================
113113

114114
#. **$db->escapeLikeString()** This method should be used when
115115
strings are to be used in LIKE conditions so that LIKE wildcards
116116
('%', '\_') in the string are also properly escaped.
117+
This function escapes the data passed to
118+
it, regardless of type. Most of the time you'll use the above
119+
function rather than this one. Use the function like this:
120+
121+
.. literalinclude:: queries/010.php
122+
123+
3. $db->escapeLikeString()
124+
==========================
125+
117126

118127
.. literalinclude:: queries/011.php
119128

@@ -162,7 +171,8 @@ placeholders in the query:
162171
Handling Errors
163172
***************
164173

165-
**$db->error();**
174+
$db->error()
175+
============
166176

167177
If you need to get the last error that has occurred, the ``error()`` method
168178
will return an array containing its code and message. Here's a quick
@@ -220,23 +230,26 @@ Other Methods
220230

221231
In addition to these two primary methods, the prepared query object also has the following methods:
222232

223-
**close()**
233+
close()
234+
-------
224235

225236
While PHP does a pretty good job of closing all open statements with the database it's always a good idea to
226237
close out the prepared statement when you're done with it:
227238

228239
.. literalinclude:: queries/020.php
229240

230-
**getQueryString()**
241+
getQueryString()
242+
----------------
231243

232244
This returns the prepared query as a string.
233245

234-
**hasError()**
246+
hasError()
247+
----------
235248

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

238-
**getErrorCode()**
239-
**getErrorMessage()**
251+
getErrorCode() getErrorMessage()
252+
--------------------------------
240253

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

@@ -249,7 +262,8 @@ Internally, all queries are processed and stored as instances of
249262
the parameters, otherwise preparing the query, and storing performance
250263
data about its query.
251264

252-
**getLastQuery()**
265+
getLastQuery()
266+
==============
253267

254268
When you just need to retrieve the last Query object, use the
255269
getLastQuery() method:
@@ -263,7 +277,8 @@ Each query object stores several pieces of information about the query itself.
263277
This is used, in part, by the Timeline feature, but is available for your use
264278
as well.
265279

266-
**getQuery()**
280+
getQuery()
281+
----------
267282

268283
Returns the final query after all processing has happened. This is the exact
269284
query that was sent to the database:
@@ -274,42 +289,48 @@ This same value can be retrieved by casting the Query object to a string:
274289

275290
.. literalinclude:: queries/023.php
276291

277-
**getOriginalQuery()**
292+
getOriginalQuery()
293+
------------------
278294

279295
Returns the raw SQL that was passed into the object. This will not have any
280296
binds in it, or prefixes swapped out, etc:
281297

282298
.. literalinclude:: queries/024.php
283299

284-
**hasError()**
300+
hasError()
301+
----------
285302

286303
If an error was encountered during the execution of this query this method
287304
will return true:
288305

289306
.. literalinclude:: queries/025.php
290307

291-
**isWriteType()**
308+
isWriteType()
309+
-------------
292310

293311
Returns true if the query was determined to be a write-type query (i.e.,
294312
INSERT, UPDATE, DELETE, etc):
295313

296314
.. literalinclude:: queries/026.php
297315

298-
**swapPrefix()**
316+
swapPrefix()
317+
------------
299318

300319
Replaces one table prefix with another value in the SQL. The first
301320
parameter is the original prefix that you want replaced, and the second
302321
parameter is the value you want it replaced with:
303322

304323
.. literalinclude:: queries/027.php
305324

306-
**getStartTime()**
325+
getStartTime()
326+
--------------
307327

308328
Gets the time the query was executed in seconds with microseconds:
309329

310330
.. literalinclude:: queries/028.php
311331

312-
**getDuration()**
332+
getDuration()
333+
-------------
313334

314335
Returns a float with the duration of the query in seconds with microseconds:
315336

0 commit comments

Comments
 (0)