@@ -102,65 +102,24 @@ public function groupConcat($field, string $delimiter = ',')
102
102
return $ this ->expr ('listagg({field}, []) within group (order by {field}) ' , ['field ' => $ field , $ delimiter ]);
103
103
}
104
104
105
- // {{{ for Oracle 11 and lower to support LIMIT with OFFSET
106
-
107
- protected $ template_select = '[with]select[option] [field] [from] [table][join][where][group][having][order] ' ;
108
- /** @var string */
109
- protected $ template_select_limit = 'select * from (select "__t".*, rownum "__dsql_rownum" [from] ([with]select[option] [field] [from] [table][join][where][group][having][order]) "__t") where "__dsql_rownum" > [limit_start][and_limit_end] ' ;
110
-
111
- public function limit ($ cnt , $ shift = null )
112
- {
113
- $ this ->template_select = $ this ->template_select_limit ;
114
-
115
- return parent ::limit ($ cnt , $ shift );
116
- }
117
-
118
105
public function _render_limit_start (): string
119
106
{
120
107
return (string ) ($ this ->args ['limit ' ]['shift ' ] ?? 0 );
121
108
}
122
109
123
- public function _render_and_limit_end (): ?string
110
+ public function _render_limit (): ?string
124
111
{
125
- if (!$ this ->args ['limit ' ][ ' cnt ' ] ) {
126
- return '' ;
112
+ if (!isset ( $ this ->args ['limit ' ]) ) {
113
+ return null ;
127
114
}
128
115
129
- return ' and "__dsql_rownum" <= '
130
- . max ((int ) ($ this ->args ['limit ' ]['cnt ' ] + $ this ->args ['limit ' ]['shift ' ]), (int ) $ this ->args ['limit ' ]['cnt ' ]);
131
- }
132
-
133
- public function getRowsIterator (): \Traversable
134
- {
135
- foreach (parent ::getRowsIterator () as $ row ) {
136
- unset($ row ['__dsql_rownum ' ]);
116
+ $ cnt = (int ) $ this ->args ['limit ' ]['cnt ' ];
117
+ $ shift = (int ) $ this ->args ['limit ' ]['shift ' ];
137
118
138
- yield $ row ;
139
- }
119
+ return ( $ shift ? ' offset ' . $ shift . ' rows ' : '' )
120
+ . ( $ cnt ? ' fetch next ' . $ cnt . ' rows only ' : '' );
140
121
}
141
122
142
- public function getRows (): array
143
- {
144
- return array_map (function ($ row ) {
145
- unset($ row ['__dsql_rownum ' ]);
146
-
147
- return $ row ;
148
- }, parent ::getRows ());
149
- }
150
-
151
- public function getRow (): ?array
152
- {
153
- $ row = parent ::getRow ();
154
-
155
- if ($ row !== null ) {
156
- unset($ row ['__dsql_rownum ' ]);
157
- }
158
-
159
- return $ row ;
160
- }
161
-
162
- /// }}}
163
-
164
123
public function exists ()
165
124
{
166
125
return $ this ->dsql ()->mode ('select ' )->field (
0 commit comments