PMA\libraries\controllers\table\TableSearchController::_buildSqlQuery PHP Method

_buildSqlQuery() private method

Builds the sql search query from the post parameters
private _buildSqlQuery ( ) : string
return string the generated SQL query
    private function _buildSqlQuery()
    {
        $sql_query = 'SELECT ';
        // If only distinct values are needed
        $is_distinct = isset($_POST['distinct']) ? 'true' : 'false';
        if ($is_distinct == 'true') {
            $sql_query .= 'DISTINCT ';
        }
        // 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 (isset($_POST['zoom_submit']) || !empty($_POST['displayAllColumns'])) {
            $sql_query .= '* ';
        } else {
            $sql_query .= implode(', ', Util::backquote($_POST['columnsToDisplay']));
        }
        // end if
        $sql_query .= ' FROM ' . Util::backquote($_POST['table']);
        $whereClause = $this->_generateWhereClause();
        $sql_query .= $whereClause;
        // if the search results are to be ordered
        if (isset($_POST['orderByColumn']) && $_POST['orderByColumn'] != '--nil--') {
            $sql_query .= ' ORDER BY ' . Util::backquote($_POST['orderByColumn']) . ' ' . $_POST['order'];
        }
        // end if
        return $sql_query;
    }