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问题_Php_Codeigniter - Fatal编程技术网

Php 带极限的CodeIgniter问题

Php 带极限的CodeIgniter问题,php,codeigniter,Php,Codeigniter,我有一个LoteModel: public function selecionar($where = NULL, $limit = NULL, $order_by = NULL) { if(!is_null($where)) { $this->db->where($where); } if(!is_null($limit)) { $this->

我有一个LoteModel:

public function selecionar($where = NULL, $limit = NULL, $order_by = NULL) {
            if(!is_null($where)) {
                $this->db->where($where);
            }
            if(!is_null($limit)) {
                $this->db->limit($limit);
            }
            if(!is_null($order_by)) {
                $this->db->order_by($order_by);
            }

            return $this->db->get(_LOTE_);//_LOTE_ is a constant for my table name
    }
我这样称呼它:

$config['per_page'] = '5';

$limite = $config['per_page'].','.$this->uri->segment(3); //the segment is ok, I receive it

$lotes = $this->LoteModel->selecionar(array('quadra_id'=>$quadra_id, 'lote_status'=>1), $limite, 'lote_endereco'); 
我已检查该查询的SQL结果:

SELECT * FROM (`realestate_lote`) WHERE `quadra_id` = '1' AND `lote_status` = 1 ORDER BY `lote_endereco` 
问题是,它没有生成我的限制,只有将它添加到LoteModel方法中,它才会起作用

我正在进行分页


提前感谢您的帮助=)

您不能将类似“5,1”的字符串传递给CI的ActiveRecord limit函数。 该函数需要两个参数

将限制字符串拆分为“,”并传递两个值,如下面的示例所示

$limit = explode(',', $limit);
$this->db->limit($limit[0], $limit[1]);

希望这有帮助…

您不能将类似“5,1”的字符串传递给CI的ActiveRecord限制函数。 该函数需要两个参数

将限制字符串拆分为“,”并传递两个值,如下面的示例所示

$limit = explode(',', $limit);
$this->db->limit($limit[0], $limit[1]);

希望这有帮助……

我发现了问题,但没有找到解决方案:极限只接受极限(10,20),而不接受极限('10,20')。我不知道怎么解决这个问题,有人吗?我找到了解决的办法。我可以发送一个数组作为我的限制参数:$lotes=$this->LoteModel->selecionar(数组('quadra\u id'=>$quadra\u id,'lote\u status'=>1),数组('x'=>10,'y'=>20),'lote\u endereco');或者将我的LoteModel更改为:公共函数selecionar($where=NULL,$limit\u start=NULL,$limit\u end=NULL,$order\u by=NULL){我发现了问题,但没有找到解决方案:限制只接受limit(10,20),而不接受limit('10,20')当我在做的时候。我不知道如何解决这个问题,有人吗?我找到了一个解决方法。我可以发送一个数组作为我的限制参数:$lotes=$this->LoteModel->selecionar(数组('quadra_id'=>quadra_id,'lote_status'=>1),数组('x'=>10,'y'=>20),'lote_endereco');或者将我的LoteModel更改为:公共函数selecionar($where=NULL,$limit\u start=NULL,$limit\u end=NULL,$order\u by=NULL){