summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-07-24 11:36:17 +0200
committerAndrey Andreev <narf@devilix.net>2015-07-24 11:36:17 +0200
commit76ac657db0b719ce83a945fb4739ae811d4ef0fd (patch)
treea9cd38e0c81ee518844beaa395eef9fca91a7667
parent6d7f87a9b2ce2950e568162e21c96af4c201147a (diff)
parent752f5692594fc0b77dffa8055bbf934e1958364f (diff)
Merge pull request #3993 from lonnieezell/f/dbnumrows
[ci skip] Removing use of num_rows() in DB results docs
-rw-r--r--user_guide_src/source/database/results.rst29
1 files changed, 13 insertions, 16 deletions
diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst
index 5f5fafd38..ddaf4c074 100644
--- a/user_guide_src/source/database/results.rst
+++ b/user_guide_src/source/database/results.rst
@@ -33,15 +33,12 @@ If you run queries that might **not** produce a result, you are
encouraged to test the result first::
$query = $this->db->query("YOUR QUERY");
-
- if ($query->num_rows() > 0)
+
+ foreach ($query->result() as $row)
{
- foreach ($query->result() as $row)
- {
- echo $row->title;
- echo $row->name;
- echo $row->body;
- }
+ echo $row->title;
+ echo $row->name;
+ echo $row->body;
}
You can also pass a string to result() which represents a class to
@@ -83,11 +80,11 @@ one row, it returns only the first row. The result is returned as an
**object**. Here's a usage example::
$query = $this->db->query("YOUR QUERY");
-
- if ($query->num_rows() > 0)
+
+ $row = $query->row();
+
+ if (isset($row))
{
- $row = $query->row();
-
echo $row->title;
echo $row->name;
echo $row->body;
@@ -113,11 +110,11 @@ Identical to the above ``row()`` method, except it returns an array.
Example::
$query = $this->db->query("YOUR QUERY");
-
- if ($query->num_rows() > 0)
+
+ $row = $query->row_array();
+
+ if (isset($row))
{
- $row = $query->row_array();
-
echo $row['title'];
echo $row['name'];
echo $row['body'];