Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter自定义\u结果\u对象类参数_Php_Codeigniter_Model View Controller - Fatal编程技术网

Php CodeIgniter自定义\u结果\u对象类参数

Php CodeIgniter自定义\u结果\u对象类参数,php,codeigniter,model-view-controller,Php,Codeigniter,Model View Controller,在我的模型中,我有: 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_

在我的模型中,我有:

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;
}
控制器

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....

Proprietati类是否作为ci库加载?您唯一的选择是在application/core中编写MY_DB_result类,并重写自定义_result_对象。像这样。那么这是通过该解析的唯一选项?@IonVasile您还可以获得一个结果数组并将您的类作为库加载。在这里,您可以选择在构造函数中传递选项,但您可能需要稍微更改构造函数实现以添加其他参数。