编码器中的限制条款不起作用

时间:2016-01-03 14:32:53

标签: php codeigniter

我在以下代码中的限制不起作用。查询获取所有记录:

    $this->db->select('users.id as user_id');
    $this->db->select('users.username');
    $this->db->select('traction_details.title');
    $this->db->select('traction_details.tr_id');
    $this->db->select('tractions.buy_id');
    $this->db->select('tractions.coupon_code');
    $this->db->select('tractions.coupon_property_id');
    $this->db->select('tractions.expired');


    $this->db->from('tractions');


    $this->db->join('traction_details' , 'traction_details.tr_id = tractions.id');
    $this->db->join('users' , 'tractions.user_id = users.id');
    $this->db->join('coupon_cats' , 'tractions.coupon_parent = coupon_cats.coupon_id');
    $this->db->where('coupon_cats.cat_id =' , '13');
    $this->db->where('tractions.succ =' , '1');

    $this->db->group_by('tractions.buy_id');
    $this->db->order_by('traction_details.tr_id', 'desc');

    $this->db->limit(0, 10);


    $result = $this->db->get()->result();

    return $result;

1 个答案:

答案 0 :(得分:2)

limit()中的第二个参数允许您设置结果偏移量,因此您需要将限制和偏移量反转为,

..
$this->db->limit(0, 10);
..

..
$this->db->limit(10, 0);
..