You can create a helper for ease of use:
Code:
if (!function_exists('numRows'))
{
/**
* Accepts database result object and returns number of rows found.
* CI 4 does not have CI 3 method $query->num_rows() thus the need for this function.
*
* @param obj $dbObject The returned database object from running query.
*
* @return int The row count.
*/
function numRows($dbObject): int
{
return $dbObject->resultID->num_rows;
}
}