【发布时间】:2015-11-12 08:32:08
【问题描述】:
在我的模型中,我有:
function select_by_limit($start, $limit) {
$this->db->from($this->_table.' a');
$this->db->join('zone b', "a.id_zona = b.id_zona", 'left');
$this->db->join('tip_proprietate c', "a.id_tip_proprietate = c.id_tip_proprietate");
$this->db->limit($limit, $start);
$query = $this->db->get_compiled_select();
$result = $this->db->query($query);
return $result->custom_result_object('Proprietati');
}
所以我使用自定义对象类 Proprietati。但是如何发送参数以便在构造函数中获取它?
public function __construct($resolution = 270){
$this->_resolution = $resolution;
}
【问题讨论】:
-
Proprietati类是否作为 ci 库加载? -
您唯一的选择是在
application/core中编写MY_DB_result类并覆盖custom_result_object()。 codeigniter.com/user_guide/general/core_classes.html -
那么这是通过该决议的唯一选择吗?
-
@IonVasile 您还可以获得一个 result_array() 并将您的类加载为库。您可以选择在构造函数中传递选项,但您可能需要稍微更改构造函数实现以添加其他参数。
标签: php codeigniter model-view-controller