diff options
author | Sebastian Mendel <cybot_tm@users.sourceforge.net> | 2007-03-15 20:15:59 +0300 |
---|---|---|
committer | Sebastian Mendel <cybot_tm@users.sourceforge.net> | 2007-03-15 20:15:59 +0300 |
commit | d4164091ff341f0eace0e06591e703989a879fef (patch) | |
tree | 8fdf07e5a08561a4bbd75ae6669ab0b55794a748 /tbl_export.php | |
parent | cf6de45646e54a2859a8fddbb99beaeb7f621a7c (diff) |
bug #1674972 no export with %afm%
Diffstat (limited to 'tbl_export.php')
-rw-r--r-- | tbl_export.php | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/tbl_export.php b/tbl_export.php index d4ea66b613..f96a11b5ce 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -39,16 +39,21 @@ if (isset($sql_query)) { $sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; } - if (isset($primary_key) && is_array($primary_key)) { - $sql_query .= ' WHERE '; - $conj = ''; - foreach ($primary_key AS $i => $key) { - $sql_query .= $conj . '( ' . $key . ' ) '; - $conj = 'OR '; - } - } elseif (!empty($analyzed_sql[0]['where_clause'])) { - $sql_query .= ' WHERE ' . $analyzed_sql[0]['where_clause']; + $wheres = array(); + + if (isset($primary_key) && is_array($primary_key) + && count($primary_key) > 0) { + $wheres[] = '(' . implode(') OR (',$primary_key) . ')'; + } + + if (!empty($analyzed_sql[0]['where_clause'])) { + $wheres[] = $analyzed_sql[0]['where_clause']; + } + + if (count($wheres) > 0 ) { + $sql_query .= ' WHERE (' . implode(') AND (', $wheres) . ')'; } + if (!empty($analyzed_sql[0]['group_by_clause'])) { $sql_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause']; } @@ -72,20 +77,20 @@ if (isset($sql_query)) { } if (!$inside_bracket && $parsed_sql[$i]['type'] == 'alpha_reservedWord' && strtoupper($parsed_sql[$i]['data']) == 'LIMIT') { // We found LIMIT to remove - + $sql_query = ''; - + // Concatenate parts before for ($j = 0; $j < $i; $j++) { $sql_query .= $parsed_sql[$j]['data'] . ' '; } - + // Skip LIMIT $i++; while ($i < $parsed_sql['len'] && - ($parsed_sql[$i]['type'] != 'alpha_reservedWord' || - ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'OFFSET'))) { - $i++; + ($parsed_sql[$i]['type'] != 'alpha_reservedWord' || + ($parsed_sql[$i]['type'] == 'alpha_reservedWord' && $parsed_sql[$i]['data'] == 'OFFSET'))) { + $i++; } // Add remaining parts |