Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChanaka Indrajith <pe.chanaka.ck@gmail.com>2012-11-01 21:49:29 +0400
committerChanaka Indrajith <pe.chanaka.ck@gmail.com>2012-11-01 21:49:29 +0400
commit6b0e05889607942fc99e3cf4accf0ec40d702552 (patch)
tree29d79fd183279fd47263647afb2c0ea8b0892224 /tbl_export.php
parent8831f48c4fc77703108d04cd645bbf7ac2e41b8b (diff)
Generate correct SQL when export set of resulted rows
Diffstat (limited to 'tbl_export.php')
-rw-r--r--tbl_export.php36
1 files changed, 12 insertions, 24 deletions
diff --git a/tbl_export.php b/tbl_export.php
index 6dfd6960ea..2158b7e869 100644
--- a/tbl_export.php
+++ b/tbl_export.php
@@ -35,33 +35,21 @@ if (! empty($sql_query)) {
// Need to generate WHERE clause?
if (isset($where_clause)) {
- // Yes => rebuild query from scratch; this doesn't work with nested
- // selects :-(
- $sql_query = 'SELECT ';
- if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
- $sql_query .= ' DISTINCT ';
- }
-
- $sql_query .= $analyzed_sql[0]['select_expr_clause'];
-
- if (!empty($analyzed_sql[0]['from_clause'])) {
- $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
- }
+ $temp_sql_array = explode("where", strtolower($sql_query));
- $wheres = array();
-
- if (isset($where_clause) && is_array($where_clause)
- && count($where_clause) > 0) {
- $wheres[] = '(' . implode(') OR (', $where_clause) . ')';
- }
-
- if (!empty($analyzed_sql[0]['where_clause'])) {
- $wheres[] = $analyzed_sql[0]['where_clause'];
- }
+ // The fields which is going to select will remain
+ // as it is regardless of the where clause(s).
+ // EX :- The part "SELECT `id`, `name` FROM `customers`"
+ // will remain same when representing the resulted rows
+ // from the following query,
+ // "SELECT `id`, `name` FROM `customers` WHERE id NOT IN
+ // ( SELECT id FROM companies WHERE name LIKE '%u%')"
+ $sql_query = $temp_sql_array[0];
- if (count($wheres) > 0) {
- $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')';
+ // Append the where clause using the primary key of each row
+ if (is_array($where_clause) && (count($where_clause) > 0)) {
+ $sql_query .= ' WHERE (' . implode(') OR (', $where_clause) . ')';
}
if (!empty($analyzed_sql[0]['group_by_clause'])) {