diff --git a/htdocs/sql/tbl_export.php b/htdocs/sql/tbl_export.php new file mode 100755 --- /dev/null +++ b/htdocs/sql/tbl_export.php @@ -0,0 +1,92 @@ + rebuild query from scracts, 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']; + } + + $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']; + } + if (!empty($analyzed_sql[0]['having_clause'])) { + $sql_query .= ' HAVING ' . $analyzed_sql[0]['having_clause']; + } + if (!empty($analyzed_sql[0]['order_by_clause'])) { + $sql_query .= ' ORDER BY ' . $analyzed_sql[0]['order_by_clause']; + } + } else { + // Just crop LIMIT clause + $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; + } + $message = $GLOBALS['strSuccess']; +} + +/** + * Displays top menu links + */ +require './libraries/tbl_links.inc.php'; + +$export_type = 'table'; +require_once './libraries/display_export.lib.php'; + + +/** + * Displays the footer + */ +require_once './libraries/footer.inc.php'; +?>