Hai*_*ood 2 php mysql codeigniter sql-limit
我有两个变量$take(limit)和$skip(offset),它们是mysql中limit子句的值。
现在,代码点火器向后执行它的limit子句。
例如
$this->db->limit(5,10)将LIMIT 10, 5在MYSQL中生成。
无论如何,我很难理解如何limit根据设置的两个值中的哪一个来调用函数。
基本上,
如果都设置了,我想打电话
$this->db->limit($take, $skip)
如果只$take设置了我想打电话
$this->db->limit($take)
但是,如果只有$skip is set, e.g. 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)
Run Code Online (Sandbox Code Playgroud)
根据Mysql文档
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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14857 次 |
| 最近记录: |