Skip to content

Commit 43a674b

Browse files
author
Radovan Janjic
committed
FIXED: query2CSV LIMIT REGEX detection bug.
1 parent 73b8c0e commit 43a674b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

MySQL_wrapper.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ function query2CSV($sql, $file, $delimiter = ',', $enclosure = '"', $escape = '\
439439
$sql = trim(rtrim(trim($sql), ';'));
440440
// Prepare SQL for column names
441441
if ($showColumns) {
442-
$r = $this->query(preg_replace('/limit(([\s]+[\d]+[\s]*,[\s]*[\d]+)|([\s]+[\d]))$/i', 'LIMIT 1;', $sql), $this->link);
442+
$regex = '/limit(([\s]+([\d]+)[\s]*,[\s]*([\d]+))|([\s]+([\d]+)))$/i';
443+
$r = $this->query((preg_match($regex, $sql)) ? preg_replace($regex, 'LIMIT 1;', $sql) : $sql . ' LIMIT 1;', $this->link);
443444
if ($r !== FALSE && $this->affected > 0) {
444445
$columns = $this->fetchArray($r);
445446
$this->freeResult($r);

0 commit comments

Comments
 (0)