mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Update limit() for Sqlite.
It should behave as the parent class does.
This commit is contained in:
parent
7b0af659a9
commit
00569ea405
2 changed files with 26 additions and 6 deletions
|
@ -377,13 +377,9 @@ class Sqlite extends DboSource {
|
|||
*/
|
||||
public function limit($limit, $offset = null) {
|
||||
if ($limit) {
|
||||
$rt = '';
|
||||
if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) {
|
||||
$rt = ' LIMIT';
|
||||
}
|
||||
$rt .= ' ' . $limit;
|
||||
$rt = sprintf(' LIMIT %u', $limit);
|
||||
if ($offset) {
|
||||
$rt .= ' OFFSET ' . $offset;
|
||||
$rt .= sprintf(' OFFSET %u', $offset);
|
||||
}
|
||||
return $rt;
|
||||
}
|
||||
|
|
|
@ -473,4 +473,28 @@ class SqliteTest extends CakeTestCase {
|
|||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the limit function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLimit() {
|
||||
$db = $this->Dbo;
|
||||
|
||||
$result = $db->limit('0');
|
||||
$this->assertNull($result);
|
||||
|
||||
$result = $db->limit('10');
|
||||
$this->assertEquals(' LIMIT 10', $result);
|
||||
|
||||
$result = $db->limit('FARTS', 'BOOGERS');
|
||||
$this->assertEquals(' LIMIT 0 OFFSET 0', $result);
|
||||
|
||||
$result = $db->limit(20, 10);
|
||||
$this->assertEquals(' LIMIT 20 OFFSET 10', $result);
|
||||
|
||||
$result = $db->limit(10, 300000000000000000000000000000);
|
||||
$this->assertEquals(' LIMIT 10 OFFSET 0', $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue