gpt4 book ai didi

php - CodeIgniter 事件记录偏移无限制?

转载 作者:行者123 更新时间:2023-11-29 01:22:43 25 4
gpt4 key购买 nike

我有两个变量,$take(限制)和$skip(偏移量),它们是 mysql 中限制子句的值。

现在 Code Igniter 向后执行限制子句。

例如

$this->db->limit(5,10) 将在 MYSQL 中生成 LIMIT 10, 5

无论如何,我很难理解如何根据设置的两个值调用 limit 函数。

基本上,

如果他们都设置好了我想打电话

$this->db->limit($take, $skip)

如果只设置了$take我想调用

$this->db->limit($take)

但是如果只设置了 $skip 我该怎么称呼,例如if$skip = 10` 那么我想显示除前 10 行之外的所有行。

我打电话吗

$this->db->limit(null, $skip)
$this->db->limit(0, $skip)
$this->db->limit(false, $skip)
完全不同的东西?

最佳答案

我认为您通过回答我们自己的问题找到了您正在寻找的答案,但是如果您想使用 codeigniter 获取除前 10 行之外的所有行,那么您需要执行类似的操作(我尚未对其进行测试) :

$this->db->limit(18446744073709551615, 10)

根据 Mysql Documentation

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter.

关于php - CodeIgniter 事件记录偏移无限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13734076/

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