CodeIgniter Forums
Number of rows in Query Results - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Number of rows in Query Results (/showthread.php?tid=69891)



Number of rows in Query Results - iceleo - 01-27-2018

Hi,

I think this feature is useful, sometime I need to check the value exists in database. Of course I can check by if $query->getRow() like this

PHP Code:
if ($query->getRow()) {...} 

In some case, I want to get the total of rows, I must do like this
PHP Code:
$rows $query->getResult();
$count count($rows); 
So I prefer to use a simple way like $query->getNumRows();

Thank!


RE: Number of rows in Query Results - Elias - 01-27-2018

If I understood you right, in CI4 there is countAllResults() method
https://github.com/bcit-ci/CodeIgniter4/blob/develop/system/Database/BaseBuilder.php (line 1405)

and count_all_results() method in CI3
https://www.codeigniter.com/userguide3/database/query_builder.html