Welcome Guest, Not a member yet? Register   Sign In
Migrating CI3 to CI4, need query->numRows function
#12

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;
    }

}
Reply


Messages In This Thread
RE: Migrating CI3 to CI4, need query->numRows function - by plaztic - 01-25-2021, 10:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB