diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2013-05-26 20:13:33 +0400 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2013-05-26 20:13:33 +0400 |
commit | 2baf473ad70b1358fca776ed05c3efbc7e99696e (patch) | |
tree | d34a0026b3ffa1fe2ecf554a30bcb2b1efe0691c /tbl_export.php | |
parent | 0dab7f2463ada776ce9b1a8671fa30573777809c (diff) | |
parent | b8e4f346a5c0b029cc25887c990a190d22c0f18c (diff) |
Merge branch 'master' into OOP_DBI
Conflicts:
libraries/database_interface.lib.php
Diffstat (limited to 'tbl_export.php')
-rw-r--r-- | tbl_export.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tbl_export.php b/tbl_export.php index 557dcb352b..ea7e66ef57 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -37,14 +37,27 @@ if (! empty($sql_query)) { // Need to generate WHERE clause? if (isset($where_clause)) { - $temp_sql_array = preg_split("/\bwhere\b/i", $sql_query); + // Regular expressions which can appear in sql query, + // before the sql segment which remains as it is. + $regex_array = array( + '/\bwhere\b/i', '/\bgroup by\b/i', '/\bhaving\b/i', '/\border by\b/i' + ); + + $first_occurring_regex = PMA_Util::getFirstOccurringRegularExpression( + $regex_array, $sql_query + ); + unset($regex_array); // The part "SELECT `id`, `name` FROM `customers`" - // is not modified by the next code segment, when exporting + // is not modified by the next code segment, when exporting // the result set from a query such as // "SELECT `id`, `name` FROM `customers` WHERE id NOT IN // ( SELECT id FROM companies WHERE name LIKE '%u%')" - $sql_query = $temp_sql_array[0]; + if (! is_null($first_occurring_regex)) { + $temp_sql_array = preg_split($first_occurring_regex, $sql_query); + $sql_query = $temp_sql_array[0]; + } + unset($first_occurring_regex, $temp_sql_array); // Append the where clause using the primary key of each row if (is_array($where_clause) && (count($where_clause) > 0)) { @@ -62,7 +75,8 @@ if (! empty($sql_query)) { } } else { // Just crop LIMIT clause - $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; + $sql_query = $analyzed_sql[0]['section_before_limit'] + . $analyzed_sql[0]['section_after_limit']; } echo PMA_Util::getMessage(PMA_Message::success()); } |