@@ -97,70 +97,24 @@ protected function _sub_render_condition(array $row): string
97
97
return parent ::_sub_render_condition ($ row );
98
98
}
99
99
100
- public function groupConcat ($ field , string $ delimiter = ', ' )
101
- {
102
- return $ this ->expr ('listagg({field}, []) within group (order by {field}) ' , ['field ' => $ field , $ delimiter ]);
103
- }
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
- public function _render_limit_start (): string
119
- {
120
- return (string ) ($ this ->args ['limit ' ]['shift ' ] ?? 0 );
121
- }
122
-
123
- public function _render_and_limit_end (): ?string
100
+ public function _render_limit (): ?string
124
101
{
125
- if (!$ this ->args ['limit ' ][ ' cnt ' ] ) {
126
- return '' ;
102
+ if (!isset ( $ this ->args ['limit ' ]) ) {
103
+ return null ;
127
104
}
128
105
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 ' ]);
137
-
138
- yield $ row ;
139
- }
140
- }
141
-
142
- public function getRows (): array
143
- {
144
- return array_map (function ($ row ) {
145
- unset($ row ['__dsql_rownum ' ]);
106
+ $ cnt = (int ) $ this ->args ['limit ' ]['cnt ' ];
107
+ $ shift = (int ) $ this ->args ['limit ' ]['shift ' ];
146
108
147
- return $ row ;
148
- }, parent :: getRows () );
109
+ return ( $ shift ? ' offset ' . $ shift . ' rows ' : '' )
110
+ . ( $ cnt ? ' fetch next ' . $ cnt . ' rows only ' : '' );
149
111
}
150
112
151
- public function getRow (): ? array
113
+ public function groupConcat ( $ field , string $ delimiter = ' , ' )
152
114
{
153
- $ row = parent ::getRow ();
154
-
155
- if ($ row !== null ) {
156
- unset($ row ['__dsql_rownum ' ]);
157
- }
158
-
159
- return $ row ;
115
+ return $ this ->expr ('listagg({field}, []) within group (order by {field}) ' , ['field ' => $ field , $ delimiter ]);
160
116
}
161
117
162
- /// }}}
163
-
164
118
public function exists ()
165
119
{
166
120
return $ this ->dsql ()->mode ('select ' )->field (
0 commit comments