在我的模型中,我有:
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');
}
所以我使用自定义对象类Ownerati。但是,我怎样才能发送一个参数,以便在构造函数中获取它呢?
public function __construct($resolution = 270){
$this->_resolution = $resolution;
}
控制器
class foo extends CI_Controller {
protected $_resolution;
public function __construct($resolution = 270){
$this->_resolution = $resolution;
}
将$resolution传递给模型函数
public function using_model($start, $limit, $this->resolution);
在模型中
function select_by_limit($start, $limit, $resolution) {
//whatever happens here....