Use existing function to build SQL query

This commit is contained in:
Atul Pratap Singh 2012-06-01 21:32:11 +05:30
parent 0223a533de
commit 6a85bdd16f
2 changed files with 5 additions and 29 deletions

View File

@ -437,7 +437,9 @@ function PMA_tblSearchBuildSqlQuery()
// if all column names were selected to display, we do a 'SELECT *'
// (more efficient and this helps prevent a problem in IE
// if one of the rows is edited and we come back to the Select results)
if (count($_POST['columnsToDisplay']) == count($_POST['criteriaColumnNames'])) {
if (count($_POST['columnsToDisplay']) == count($_POST['criteriaColumnNames'])
|| isset($_POST['zoom_submit'])
) {
$sql_query .= '* ';
} else {
$sql_query .= implode(', ', PMA_backquote($_POST['columnsToDisplay']));
@ -448,7 +450,7 @@ function PMA_tblSearchBuildSqlQuery()
$sql_query .= $whereClause;
// if the search results are to be ordered
if ($_POST['orderByColumn'] != '--nil--') {
if (isset($_POST['orderByColumn']) && $_POST['orderByColumn'] != '--nil--') {
$sql_query .= ' ORDER BY ' . PMA_backquote($_POST['orderByColumn'])
. ' ' . $_POST['order'];
} // end if

View File

@ -346,33 +346,7 @@ if (isset($zoom_submit)
/*
* Query generation part
*/
$w = $data = array();
$sql_query = 'SELECT *';
//Add the table
$sql_query .= ' FROM ' . PMA_backquote($table);
for ($i = 0; $i < 4; $i++) {
if ($criteriaColumnNames[$i] == 'pma_null') {
continue;
}
$tmp = array();
// The where clause
$charsets = array();
$cnt_func = count($criteriaColumnOperators[$i]);
$func_type = $criteriaColumnOperators[$i];
list($charsets[$i]) = explode('_', $criteriaColumnCollations[$i]);
$unaryFlag = $GLOBALS['PMA_Types']->isUnaryOperator($func_type);
$whereClause = PMA_tbl_search_getWhereClause(
$criteriaValues[$i], $criteriaColumnNames[$i], $criteriaColumnTypes[$i],
$criteriaColumnCollations[$i], $func_type, $unaryFlag
);
if ($whereClause) {
$w[] = $whereClause;
}
} // end for
if ($w) {
$sql_query .= ' WHERE ' . implode(' AND ', $w);
}
$sql_query = PMA_tblSearchBuildSqlQuery();
$sql_query .= ' LIMIT ' . $maxPlotLimit;
/*