Code Duplication    Length = 49-49 lines in 2 locations

system/libraries/drivers/Database/Mssql.php 1 location

@@ 187-235 (lines=49) @@
184
        return 'TOP '.$limit;
185
    }
186
187
    public function compile_select($database)
188
    {
189
        $sql = ($database['distinct'] == true) ? 'SELECT DISTINCT ' : 'SELECT ';
190
        $sql .= (count($database['select']) > 0) ? implode(', ', $database['select']) : '*';
191
192
        if (count($database['from']) > 0) {
193
            // Escape the tables
194
            $froms = array();
195
            foreach ($database['from'] as $from) {
196
                $froms[] = $this->escape_column($from);
197
            }
198
            $sql .= "\nFROM ";
199
            $sql .= implode(', ', $froms);
200
        }
201
202
        if (count($database['join']) > 0) {
203
            foreach ($database['join'] as $join) {
204
                $sql .= "\n".$join['type'].'JOIN '.implode(', ', $join['tables']).' ON '.$join['conditions'];
205
            }
206
        }
207
208
        if (count($database['where']) > 0) {
209
            $sql .= "\nWHERE ";
210
        }
211
212
        $sql .= implode("\n", $database['where']);
213
214
        if (count($database['groupby']) > 0) {
215
            $sql .= "\nGROUP BY ";
216
            $sql .= implode(', ', $database['groupby']);
217
        }
218
219
        if (count($database['having']) > 0) {
220
            $sql .= "\nHAVING ";
221
            $sql .= implode("\n", $database['having']);
222
        }
223
224
        if (count($database['orderby']) > 0) {
225
            $sql .= "\nORDER BY ";
226
            $sql .= implode(', ', $database['orderby']);
227
        }
228
229
        if (is_numeric($database['limit'])) {
230
            $sql .= "\n";
231
            $sql .= $this->limit($database['limit']);
232
        }
233
234
        return $sql;
235
    }
236
237
    public function escape_str($str)
238
    {

system/libraries/drivers/Database/Mysql.php 1 location

@@ 202-250 (lines=49) @@
199
        return 'LIMIT '.$offset.', '.$limit;
200
    }
201
202
    public function compile_select($database)
203
    {
204
        $sql = ($database['distinct'] == true) ? 'SELECT DISTINCT ' : 'SELECT ';
205
        $sql .= (count($database['select']) > 0) ? implode(', ', $database['select']) : '*';
206
207
        if (count($database['from']) > 0) {
208
            // Escape the tables
209
            $froms = array();
210
            foreach ($database['from'] as $from) {
211
                $froms[] = $this->escape_column($from);
212
            }
213
            $sql .= "\nFROM (";
214
            $sql .= implode(', ', $froms).")";
215
        }
216
217
        if (count($database['join']) > 0) {
218
            foreach ($database['join'] as $join) {
219
                $sql .= "\n".$join['type'].'JOIN '.implode(', ', $join['tables']).' ON '.$join['conditions'];
220
            }
221
        }
222
223
        if (count($database['where']) > 0) {
224
            $sql .= "\nWHERE ";
225
        }
226
227
        $sql .= implode("\n", $database['where']);
228
229
        if (count($database['groupby']) > 0) {
230
            $sql .= "\nGROUP BY ";
231
            $sql .= implode(', ', $database['groupby']);
232
        }
233
234
        if (count($database['having']) > 0) {
235
            $sql .= "\nHAVING ";
236
            $sql .= implode("\n", $database['having']);
237
        }
238
239
        if (count($database['orderby']) > 0) {
240
            $sql .= "\nORDER BY ";
241
            $sql .= implode(', ', $database['orderby']);
242
        }
243
244
        if (is_numeric($database['limit'])) {
245
            $sql .= "\n";
246
            $sql .= $this->limit($database['limit'], $database['offset']);
247
        }
248
249
        return $sql;
250
    }
251
252
    public function escape_str($str)
253
    {