We have a CMS written in Kohana 2.3.x (yes, we know it is an old one). When I use the query builder like this:
$obj = ORM::factory('product')->where(array_of_wheres)->find_all()
than the $obj will be an ORM_Iterator.
But when I write something like this:
$obj = ORM::factory('product');
if($something)
$obj->where(array_of_wheres);
else
$obj->where(array_of_other_wheres);
$obj->find_all();
Than the $obj will be a Product_Model instead of ORM_Iterator.
Can someone explain why is this happening?
Thanks, Dave.
In first example
$objis result offind_all()function that is aORM_Iteratorcalled by on anonymous object of Product Model.But in 2nd example
$objis ORM object for Product Model. When you call find_all function it returns result as ORM_Iterator it does not modify original object.Here is correct way to do it