[eluser]bEz[/eluser]
I believe $countries is assigned by reference and not it's own copy of the "country->all" object. (Phil, feel free to correct me on this)
Try the below changes:
Code:
$inventory = new inventory;
$country = new country;
$country->get();
// ============================
// Comment out this line and place below
// $countries = $country->all;
// ============================
echo "Total: " . $country->count();
// ============================
// re-get() the data and then apply the "all" method.
$country->get();
$countries = $country->all;
// ============================
$i = 0;
foreach($countries as $c)
{
$i++;
}
echo "Total PHP: " . $i;
Aside from testing purposes, the above code changes should provide like numbers.
I believe, if you also used the "array" extensions. you coud do the following (untested of course).
Code:
$country = new country;
$country->load_extension('array');
$country->get();
$c_cnt = count( $country->all_to_array() );
EDIT: Above Tested.
IF all you want is a count, then the "extension" version is overkill.
IF you wanted the array, but wanted the count as well, then the extension method is the better choice.
IF you are trying to test "PHP" vs "PHP via CI" then I think you maybe fighting a useless battle.