【发布时间】:2016-05-04 09:27:34
【问题描述】:
我们有一个用 Kohana 2.3.x 编写的 CMS(是的,我们知道它是旧的)。 当我像这样使用查询生成器时:
$obj = ORM::factory('product')->where(array_of_wheres)->find_all()
比$obj 将是ORM_Iterator。
但是当我写这样的东西时:
$obj = ORM::factory('product');
if($something)
$obj->where(array_of_wheres);
else
$obj->where(array_of_other_wheres);
$obj->find_all();
$obj 将是 Product_Model 而不是 ORM_Iterator。
有人能解释一下为什么会这样吗?
谢谢,戴夫。
【问题讨论】:
-
您使用的是 PHP 5.6.21 还是 PHP 7.0.5 ?
-
我使用的是 PHP 5.5.12
-
$return = $obj->find_all() 的类型是什么;它必须是数据库结果或某种迭代器
-
In2nd 代码 $obj 是 Product Model 的实际 ORM 对象,而不是 find_all 的结果
标签: php orm kohana query-builder kohana-orm