Executing COUNT(*)will give you a single line containing the number of lines, not the results themselves.
To access COUNT(*), you will need to do
$result = $query->row_array();
$count = $result['COUNT(*)'];
The second option works much better, since it does not need to return the data set to PHP, but instead just a count and, therefore, is much more optimized.
source
share