diff options
author | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2012-07-09 22:24:18 +0400 |
---|---|---|
committer | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2012-07-09 22:24:18 +0400 |
commit | dbe87e52a4f6c957f807893bb2188aac0f17f5da (patch) | |
tree | b51caf5c67f3b273c621070e2c7fefc48e71ef13 /db_qbe.php | |
parent | f501ab3ced23750056c20e6a5ba0b7d3430e7479 (diff) |
Form function for generating SELECT clause
Diffstat (limited to 'db_qbe.php')
-rw-r--r-- | db_qbe.php | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/db_qbe.php b/db_qbe.php index 7ed278204b..1c0b75d3a0 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -568,6 +568,34 @@ function PMA_dbQbeGetModifyColumnsRow($criteria_column_count, $and_or_col, return $html_output; } +/** + * Provides SELECT clause for building SQL query + * + * @param array $criteria_column_count Number of criteria columns + * + * @return Select clause + */ +function PMA_dbQbeGetSelectClause($criteria_column_count){ + $last_select = 0; + $select_clause = ''; + for ($column_index = 0; $column_index < $criteria_column_count; $column_index++) { + if (! empty($GLOBALS['curField'][$column_index]) + && isset($GLOBALS['curShow'][$column_index]) + && $GLOBALS['curShow'][$column_index] == 'on') + { + if ($last_select) { + $select_clause .= ', '; + } + $select_clause .= $GLOBALS['curField'][$column_index]; + $last_select = 1; + } + } // end for + if (! empty($select_clause)) { + $select_clause = 'SELECT ' . htmlspecialchars($select_clause) . "\n"; + } + return $select_clause; +} + if ($cfgRelation['designerwork']) { $url = 'pmd_general.php' . PMA_generate_common_url( array_merge( @@ -799,26 +827,7 @@ echo PMA_dbQbeGetTablesList($tbl_names); dir="<?php echo $text_dir; ?>"> <?php // 1. SELECT -$last_select = 0; -if (! isset($qry_select)) { - $qry_select = ''; -} -for ($x = 0; $x < $col; $x++) { - if (! empty($GLOBALS['curField'][$x]) - && isset($GLOBALS['curShow'][$x]) - && $GLOBALS['curShow'][$x] == 'on') - { - if ($last_select) { - $qry_select .= ', '; - } - $qry_select .= $GLOBALS['curField'][$x]; - $last_select = 1; - } -} // end for -if (! empty($qry_select)) { - echo 'SELECT ' . htmlspecialchars($qry_select) . "\n"; -} - +echo PMA_dbQbeGetSelectClause($col); // 2. FROM // Create LEFT JOINS out of Relations |