gpt4 book ai didi

php - CodeIgniter 事件记录限制与连接

转载 作者:行者123 更新时间:2023-12-04 22:24:42 25 4
gpt4 key购买 nike

我的模型中有以下功能:

function getLocations($limit = null, $offset = null){
$this->db->select('*');
$this->db->from('location');
$this->db->join('process', 'process.process_id=location.process_id');
$this->db->join('line', 'line.line_id=process.line_id');
$this->db->limit($limit, $offset);
$this->db->order_by('location_id', 'asc');
return $this->db->get()->result();
}

然后使用: $this->the_model->getLocations() 执行它导致以下查询:
SELECT *
FROM "location"
JOIN "process" ON "process"."process_id"="location"."process_id"
JOIN "line" ON "line"."line_id"="process"."line_id"
ORDER BY "location_id" asc LIMIT 0

通知 LIMIT 0 ,当我执行 $this->db->order_by('item_id', 'asc')->get('item', $limit, $offset)->result() 时不会发生这种情况.没有 LIMIT 0偶数限制和偏移量是 null .那么,如何解决这个问题呢?我已经加了 if limit 为空时的条件。

最佳答案

0是一个值。这并不意味着 0NULL .虽然 NULL根本没有值(value)。

对于你的情况,

function getLocations($limit = 1, $offset = 0){
^ ^
$this->db->select('*');
$this->db->from('location');
$this->db->join('process', 'process.process_id=location.process_id');
$this->db->join('line', 'line.line_id=process.line_id');
$this->db->limit($limit, $offset);
$this->db->order_by('location_id', 'asc');
return $this->db->get()->result();
}

limit至少 1和偏移量是 0对于默认值。

关于php - CodeIgniter 事件记录限制与连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33468866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com