From 715959d5ec962431d3df4415acb798339b5a7f51 Mon Sep 17 00:00:00 2001 From: Lonnie Ezell Date: Wed, 22 Jul 2015 09:20:05 -0500 Subject: Removing use of ->num_rows() in DB results docs. --- user_guide_src/source/database/results.rst | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index ac44566d3..5bddcebb2 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -33,17 +33,15 @@ 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 instantiate for each result object (note: this class must be loaded) @@ -83,11 +81,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 (is_object($row)) { - $row = $query->row(); - echo $row->title; echo $row->name; echo $row->body; @@ -113,11 +111,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 (is_array($row)) { - $row = $query->row_array(); - echo $row['title']; echo $row['name']; echo $row['body']; -- cgit v1.2.3-24-g4f1b From f6259657756cf13c65f5ac30b36ad2d0dbdc89fc Mon Sep 17 00:00:00 2001 From: Lonnie Ezell Date: Wed, 22 Jul 2015 21:42:28 -0500 Subject: The little things. :) --- user_guide_src/source/database/results.rst | 1 - 1 file changed, 1 deletion(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 5bddcebb2..58c6b1880 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -41,7 +41,6 @@ encouraged to test the result first:: echo $row->body; } - You can also pass a string to result() which represents a class to instantiate for each result object (note: this class must be loaded) -- cgit v1.2.3-24-g4f1b From 752f5692594fc0b77dffa8055bbf934e1958364f Mon Sep 17 00:00:00 2001 From: Lonnie Ezell Date: Thu, 23 Jul 2015 23:27:01 -0500 Subject: Revamping to the tune of isset --- user_guide_src/source/database/results.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 58c6b1880..689fd52ff 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -83,7 +83,7 @@ one row, it returns only the first row. The result is returned as an $row = $query->row(); - if (is_object($row)) + if (isset($row)) { echo $row->title; echo $row->name; @@ -113,7 +113,7 @@ Example:: $row = $query->row_array(); - if (is_array($row)) + if (isset($row)) { echo $row['title']; echo $row['name']; -- cgit v1.2.3-24-g4f1b