Welcome Guest, Not a member yet? Register   Sign In
DB doesn't have num_rows/numRows ??
#9

(09-16-2018, 11:42 AM)kilishan Wrote:
(09-16-2018, 08:12 AM)skunkbad Wrote:
(09-15-2018, 10:11 PM)Paradinight Wrote: See https://github.com/bcit-ci/CodeIgniter4/pull/109

Quote:I had left the numRows out on purpose. We can always discuss whether to provide it or not but we had been discouraging its use for the last couple of years and writing it out of the user guide examples due to performance and memory issues on several platforms.

Performance and memory issues? I will refrain from issuing a harsh rebuke, but I willl say that it sounds like CI4 must have some kind of problem that CI3 didn't have. Either that or these "performance and memory issues" are insignificant and being blown out of proportion.

We appreciate you leaving out the harsh rebuke's unless you have the data to back it up. Smile The performance issues were being seen in CI3, and likely 2 also, but not in all database drivers. CI3 supported a vast amount of databases, and not all of them supported the features needed to do some of those, so the only way to issue a count of results was to pull them all out at once and count the resulting array, while other databases supported using a cursor so when you looped over results it was much faster and more memory-efficient. I don't recall which were which, and wasn't involved in CI development when those problems were found, so that's about as far as I can comment on that.

As it stands at the moment, we only have 3 databases supported, so might re-visit that. But currently focused on just getting Alpha out the door. Smile

But as that diff pointed out - you can tell if you have results by checking the response itself. If you need to know the number of results exactly, grab the results and count the returned array. Simple.

I usually just need to know if there was anything returned, and in some cases I check for 1.

Not knowing exactly how the DB libraries work under the hood, I guess I just assumed it was a simple count() of the results. I'm all for allowing CI4 to be the fastest it can be, and while the stats/data might be interesting to take a look at, I guess I'll just take your word for it. It's not a show stopper to be without num_rows().
Reply


Messages In This Thread
DB doesn't have num_rows/numRows ?? - by skunkbad - 09-15-2018, 10:51 AM
RE: DB doesn't have num_rows/numRows ?? - by skunkbad - 09-16-2018, 02:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB