Skip to content

Commit 14dea5c

Browse files
authored
Merge pull request #5986 from kenjis/fix-docs-database/results.rst
docs: improve database/results.rst
2 parents 1e08e69 + f1767b3 commit 14dea5c

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

user_guide_src/source/database/results.rst

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ There are several ways to generate query results:
1212
Result Arrays
1313
*************
1414

15-
**getResult()**
15+
getResult()
16+
===========
1617

1718
This method returns the query result as an array of **objects**, or
1819
**an empty array** on failure. Typically you'll use this in a foreach
@@ -36,7 +37,8 @@ instantiate for each result object
3637

3738
The above method is an alias of ``getCustomResultObject()``.
3839

39-
**getResultArray()**
40+
getResultArray()
41+
================
4042

4143
This method returns the query result as a pure array, or an empty
4244
array when no result is produced. Typically you'll use this in a foreach
@@ -48,7 +50,8 @@ loop, like this:
4850
Result Rows
4951
***********
5052

51-
**getRow()**
53+
getRow()
54+
========
5255

5356
This method returns a single result row. If your query has more than
5457
one row, it returns only the first row. The result is returned as an
@@ -66,7 +69,8 @@ to instantiate the row with:
6669

6770
.. literalinclude:: results/007.php
6871

69-
**getRowArray()**
72+
getRowArray()
73+
=============
7074

7175
Identical to the above ``row()`` method, except it returns an array.
7276
Example:
@@ -81,24 +85,25 @@ digit in the first parameter:
8185
In addition, you can walk forward/backwards/first/last through your
8286
results using these variations:
8387

84-
| **$row = $query->getFirstRow()**
85-
| **$row = $query->getLastRow()**
86-
| **$row = $query->getNextRow()**
87-
| **$row = $query->getPreviousRow()**
88+
| ``$row = $query->getFirstRow()``
89+
| ``$row = $query->getLastRow()``
90+
| ``$row = $query->getNextRow()``
91+
| ``$row = $query->getPreviousRow()``
8892
8993
By default they return an object unless you put the word "array" in the
9094
parameter:
9195

92-
| **$row = $query->getFirstRow('array')**
93-
| **$row = $query->getLastRow('array')**
94-
| **$row = $query->getNextRow('array')**
95-
| **$row = $query->getPreviousRow('array')**
96+
| ``$row = $query->getFirstRow('array')``
97+
| ``$row = $query->getLastRow('array')``
98+
| ``$row = $query->getNextRow('array')``
99+
| ``$row = $query->getPreviousRow('array')``
96100
97101
.. note:: All the methods above will load the whole result into memory
98102
(prefetching). Use ``getUnbufferedRow()`` for processing large
99103
result sets.
100104

101-
**getUnbufferedRow()**
105+
getUnbufferedRow()
106+
==================
102107

103108
This method returns a single result row without prefetching the whole
104109
result in memory as ``row()`` does. If your query has more than one row,
@@ -145,7 +150,8 @@ In addition to the two methods listed below, the following methods also can
145150
take a class name to return the results as: ``getFirstRow()``, ``getLastRow()``,
146151
``getNextRow()``, and ``getPreviousRow()``.
147152

148-
**getCustomResultObject()**
153+
getCustomResultObject()
154+
=======================
149155

150156
Returns the entire result set as an array of instances of the class requested.
151157
The only parameter is the name of the class to instantiate.
@@ -154,7 +160,8 @@ Example:
154160

155161
.. literalinclude:: results/014.php
156162

157-
**getCustomRowObject()**
163+
getCustomRowObject()
164+
====================
158165

159166
Returns a single row from your query results. The first parameter is the row
160167
number of the results. The second parameter is the class name to instantiate.
@@ -173,21 +180,24 @@ Example:
173180
Result Helper Methods
174181
*********************
175182

176-
**getFieldCount()**
183+
getFieldCount()
184+
===============
177185

178186
The number of FIELDS (columns) returned by the query. Make sure to call
179187
the method using your query result object:
180188

181189
.. literalinclude:: results/017.php
182190

183-
**getFieldNames()**
191+
getFieldNames()
192+
===============
184193

185194
Returns an array with the names of the FIELDS (columns) returned by the query.
186195
Make sure to call the method using your query result object:
187196

188197
.. literalinclude:: results/018.php
189198

190-
**getNumRows()**
199+
getNumRows()
200+
============
191201

192202
The number of records returned by the query. Make sure to call
193203
the method using your query result object:
@@ -198,7 +208,8 @@ the method using your query result object:
198208
CodeIgniter will fetch and buffer the query result records internally and
199209
return a count of the resulting record array, which can be inefficient.
200210

201-
**freeResult()**
211+
freeResult()
212+
============
202213

203214
It frees the memory associated with the result and deletes the result
204215
resource ID. Normally PHP frees its memory automatically at the end of
@@ -210,7 +221,8 @@ Example:
210221

211222
.. literalinclude:: results/020.php
212223

213-
**dataSeek()**
224+
dataSeek()
225+
==========
214226

215227
This method sets the internal pointer for the next result row to be
216228
fetched. It is only useful in combination with ``getUnbufferedRow()``.

0 commit comments

Comments
 (0)