Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI_DB_result::row() returns empty array when no rows found #121

Closed
bitbucket-import opened this issue Aug 19, 2011 · 4 comments
Closed

CI_DB_result::row() returns empty array when no rows found #121

bitbucket-import opened this issue Aug 19, 2011 · 4 comments
Milestone

Comments

@bitbucket-import
Copy link

CI_DB_result::row() is supposed to return an stdClass object encapsulating a single row from the query result. When there are no rows in the result, row() returns an empty array instead, which is very unexpected for a method that's supposed to return an object — expected behavior would be to return null.

I've tracked this to line 255 in system/database/DB_result.php, in the row_object() method:

{{{

!php

if (count($result) == 0)
{
return $result;
}
}}}

Edit: this apparently applies to all row-fetching methods as well (first_row(), last_row(), next_row(), previous_row()).

@narfbg
Copy link
Contributor

narfbg commented Apr 24, 2012

I know that returning an empty array is intended, but I also think it's logical that an empty object is returned. @philsturgeon ?

@philsturgeon
Copy link
Contributor

I think this should probably return NULL?

@narfbg
Copy link
Contributor

narfbg commented Apr 27, 2012

NULL or FALSE would also do, yes.

narfbg added a commit that referenced this issue May 24, 2012
@narfbg
Copy link
Contributor

narfbg commented May 24, 2012

Changed to return NULL.

@narfbg narfbg closed this as completed May 24, 2012
Dentxinho pushed a commit to Dentxinho/CodeIgniter that referenced this issue Sep 28, 2012
Fix ion library error according to bcit-ci#119 pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants