Skip to content

Commit c7e4798

Browse files
authored
refactor: OCI8 limit() method (#9472)
* refactor: OCI8 limit() method * remove the unused class property and method * phpstan - regenerate baseline
1 parent 7a177dd commit c7e4798

File tree

2 files changed

+5
-35
lines changed

2 files changed

+5
-35
lines changed

system/Database/OCI8/Builder.php

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ class Builder extends BaseBuilder
4848
*/
4949
protected $countString = 'SELECT COUNT(1) ';
5050

51-
/**
52-
* Limit used flag
53-
*
54-
* If we use LIMIT, we'll add a field that will
55-
* throw off num_fields later.
56-
*
57-
* @var bool
58-
*/
59-
protected $limitUsed = false;
60-
6151
/**
6252
* A reference to the database connection.
6353
*
@@ -214,28 +204,13 @@ protected function _update(string $table, array $values): string
214204
protected function _limit(string $sql, bool $offsetIgnore = false): string
215205
{
216206
$offset = (int) ($offsetIgnore === false ? $this->QBOffset : 0);
217-
if (version_compare($this->db->getVersion(), '12.1', '>=')) {
218-
// OFFSET-FETCH can be used only with the ORDER BY clause
219-
if (empty($this->QBOrderBy)) {
220-
$sql .= ' ORDER BY 1';
221-
}
222207

223-
return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY';
208+
// OFFSET-FETCH can be used only with the ORDER BY clause
209+
if (empty($this->QBOrderBy)) {
210+
$sql .= ' ORDER BY 1';
224211
}
225212

226-
$this->limitUsed = true;
227-
$limitTemplateQuery = 'SELECT * FROM (SELECT INNER_QUERY.*, ROWNUM RNUM FROM (%s) INNER_QUERY WHERE ROWNUM < %d)' . ($offset !== 0 ? ' WHERE RNUM >= %d' : '');
228-
229-
return sprintf($limitTemplateQuery, $sql, $offset + $this->QBLimit + 1, $offset);
230-
}
231-
232-
/**
233-
* Resets the query builder values. Called by the get() function
234-
*/
235-
protected function resetSelect()
236-
{
237-
$this->limitUsed = false;
238-
parent::resetSelect();
213+
return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY';
239214
}
240215

241216
/**

utils/phpstan-baseline/missingType.return.neon

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 201 errors
1+
# total 200 errors
22

33
parameters:
44
ignoreErrors:
@@ -112,11 +112,6 @@ parameters:
112112
count: 1
113113
path: ../../system/Database/MigrationRunner.php
114114

115-
-
116-
message: '#^Method CodeIgniter\\Database\\OCI8\\Builder\:\:resetSelect\(\) has no return type specified\.$#'
117-
count: 1
118-
path: ../../system/Database/OCI8/Builder.php
119-
120115
-
121116
message: '#^Method CodeIgniter\\Database\\Postgre\\Connection\:\:buildDSN\(\) has no return type specified\.$#'
122117
count: 1

0 commit comments

Comments
 (0)