Skip to content

Commit 6624395

Browse files
authored
Merge pull request #7379 from kenjis/docs-improve-database-results.rst
docs: improve getResult() in database/results.rst
2 parents 829bcb2 + e40d25f commit 6624395

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

user_guide_src/source/database/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
######################
2-
Working With Databases
2+
Working with Databases
33
######################
44

55
CodeIgniter comes with a full-featured and very fast abstracted database

user_guide_src/source/database/results.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ There are several ways to generate query results:
66

77
.. contents::
88
:local:
9-
:depth: 2
9+
:depth: 3
1010

1111
*************
1212
Result Arrays
@@ -16,26 +16,37 @@ getResult()
1616
===========
1717

1818
This method returns the query result as an array of **objects**, or
19-
**an empty array** on failure. Typically you'll use this in a foreach
19+
**an empty array** on failure.
20+
21+
Getting an Array of stdClass
22+
----------------------------
23+
24+
Typically you'll use this in a foreach
2025
loop, like this:
2126

2227
.. literalinclude:: results/001.php
2328

24-
The above method is an alias of ``getResultObject()``.
29+
The above method is an alias of :php:meth:`CodeIgniter\\Database\\BaseResult::getResultObject()`.
30+
31+
Getting an Array of Array
32+
-------------------------
2533

2634
You can pass in the string 'array' if you wish to get your results
2735
as an array of arrays:
2836

2937
.. literalinclude:: results/002.php
3038

31-
The above usage is an alias of ``getResultArray()``.
39+
The above usage is an alias of `getResultArray()`_.
40+
41+
Getting an Array of Custom Object
42+
---------------------------------
3243

3344
You can also pass a string to ``getResult()`` which represents a class to
3445
instantiate for each result object
3546

3647
.. literalinclude:: results/003.php
3748

38-
The above method is an alias of ``getCustomResultObject()``.
49+
The above method is an alias of `getCustomResultObject()`_.
3950

4051
getResultArray()
4152
================
@@ -272,7 +283,7 @@ Class Reference
272283
Returns the query results as an array of rows, where each
273284
row is an object of type ``stdClass``.
274285

275-
Usage: see `Result Arrays`_.
286+
Usage: see `Getting an Array of stdClass`_.
276287

277288
.. php:method:: getCustomResultObject($class_name)
278289

0 commit comments

Comments
 (0)