Skip to content

Commit 26bac2f

Browse files
author
Radovan Janjic
committed
BUG FIX: query2CSV / REGEX for detecting query limit
1 parent aa2efab commit 26bac2f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

MySQL_wrapper.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ function query2CSV($sql, $file, $delimiter = ',', $enclosure = '"', $escape = '\
419419
$file = realpath($file);
420420
unlink($file);
421421
// Remove ; from end of query
422-
$sql = rtrim(trim($sql), ';');
422+
$sql = trim(rtrim(trim($sql), ';'));
423423
// Prepare SQL for column names
424424
if ($showColumns) {
425-
$r = $this->query(preg_replace('/(limit)\s\d(((\,\s)|(\s\,\s)|(\s\,))\d)?$/i', 'LIMIT 1', $sql), $this->link);
425+
$r = $this->query(preg_replace('/limit(([\s]+[\d]+[\s]*,[\s]*[\d]+)|([\s]+[\d]))$/i', 'LIMIT 1', $sql), $this->link);
426426
if ($r !== FALSE && $this->affected > 0) {
427427
$columns = $this->fetchArray($r);
428428
$this->freeResult($r);

0 commit comments

Comments
 (0)