Skip to content

Commit

Permalink
Merge pull request #3993 from lonnieezell/f/dbnumrows
Browse files Browse the repository at this point in the history
[ci skip] Removing use of num_rows() in DB results docs
  • Loading branch information
narfbg committed Jul 24, 2015
2 parents 6d7f87a + 752f569 commit 76ac657
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions user_guide_src/source/database/results.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@pawelkg

pawelkg Jul 28, 2015

Contributor

Is it ok? We talking about test the result first, so we should leave $query->num_rows() test. Am I right?

This comment has been minimized.

Copy link
@narfbg

narfbg Jul 28, 2015

Author Contributor

No, the whole point here is that we remove it ... at least look at the pull request.

This comment has been minimized.

Copy link
@pawelkg

pawelkg Jul 28, 2015

Contributor

I looked at the pull request. This docblock is identical to previous one. Description to this docblock is 'If you run queries that might not produce a result, you are encouraged to test the result first:', but there is no test in it.

This comment has been minimized.

Copy link
@narfbg

narfbg Jul 28, 2015

Author Contributor

So the description should be removed.

This comment has been minimized.

Copy link
@pawelkg

pawelkg Jul 28, 2015

Contributor

Why remove description (which is useful) and leave this docblock? Better to undo the changes in this particular docblock.

This comment has been minimized.

Copy link
@narfbg

narfbg Jul 28, 2015

Author Contributor

This is not a docblock, it's an example that became redundant with the removal of the num_rows() in it. And because of that it was removed together with the description above it: 49ea7db

The fact that you're asking this question shows that even if you've looked at the pull request, you've made zero effort to understand it.

This comment has been minimized.

Copy link
@pawelkg

pawelkg Jul 28, 2015

Contributor

Relax. I understand why there are such changes in the documentation. What I mean is that this remark was useful and in my opinion should stay.

This comment has been minimized.

Copy link
@narfbg

narfbg Jul 28, 2015

Author Contributor

If you did understand it, you wouldn't think it's useful or that it should stay - these are opposites; like black and white, cold and heat, etc. It's a huge contradiction and that drives me insane.

But sure, you're entitled to your opinion ... let's leave it at that.

This comment has been minimized.

Copy link
@pawelkg

pawelkg Jul 28, 2015

Contributor

Okay, leave it as it is. But FYI fact that I understand something, does not imply that someone less knowledgeable may not know this. Documentation is also for beginners, where they often redirected by me.

BTW You should not be so nervous :P

Have a nice day.

This comment has been minimized.

Copy link
@narfbg

narfbg Jul 28, 2015

Author Contributor

Beginners SHOULD NOT be seeing that example, because it's bad advice - that's the whole point.


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
Expand Down Expand Up @@ -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;
Expand All @@ -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'];
Expand Down

0 comments on commit 76ac657

Please sign in to comment.