1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-11-01 23:14:58 +03:00

Introduce aliases

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne
2015-06-12 07:27:51 +05:30
parent 2a0397dd33
commit ab6b617e97

View File

@@ -128,6 +128,13 @@ class PMA_DbQbe
* @var array
*/
private $_curField;
/**
* Current alias
*
* @access private
* @var array
*/
private $_curAlias;
/**
* Current criteria Sort options
*
@@ -444,6 +451,54 @@ class PMA_DbQbe
return $html_output;
}
private function _getColumnAliasRow()
{
$html_output = '<tr class="even noclick">';
$html_output .= '<th>' . __('Alias:') . '</th>';
$new_column_count = 0;
for (
$colInd = 0;
$colInd < $this->_criteria_column_count;
$colInd++
) {
if (! empty($this->_criteriaColumnInsert)
&& isset($this->_criteriaColumnInsert[$colInd])
&& $this->_criteriaColumnInsert[$colInd] == 'on'
) {
$html_output .= '<td class="center">';
$html_output .= '<input type="text"'
. ' name="criteriaAlias[' . $new_column_count . ']"'
. ' value="" />';
$html_output .= '</td>';
$new_column_count++;
} // end if
if (! empty($this->_criteriaColumnDelete)
&& isset($this->_criteriaColumnDelete[$colInd])
&& $this->_criteriaColumnDelete[$colInd] == 'on'
) {
continue;
}
$tmp_alias = '';
if (! empty($_REQUEST['criteriaAlias'][$colInd])) {
$tmp_alias
= $this->_curAlias[$new_column_count]
= $_REQUEST['criteriaAlias'][$colInd];
}// end if
$html_output .= '<td class="center">';
$html_output .= '<input type="text"'
. ' name="criteriaAlias[' . $new_column_count . ']"'
. ' value="' . htmlspecialchars($tmp_alias) . '" />';
$html_output .= '</td>';
$new_column_count++;
} // end for
$html_output .= '</tr>';
return $html_output;
}
/**
* Provides search form's row containing sort(ASC/DESC) select options
*
@@ -983,7 +1038,12 @@ class PMA_DbQbe
&& isset($this->_curShow[$column_index])
&& $this->_curShow[$column_index] == 'on'
) {
$select_clauses[] = $this->_curField[$column_index];
$select = $this->_curField[$column_index];
if (! empty($this->_curAlias[$column_index])) {
$select .= " AS "
. PMA_Util::backquote($this->_curAlias[$column_index]);
}
$select_clauses[] = $select;
}
} // end for
if ($select_clauses) {
@@ -1487,7 +1547,7 @@ class PMA_DbQbe
// Tables that can not be combined with the table cluster
// that includes master table
$unfinalized = array_diff($allTables, array_keys($finalized));
// Add these tables are cartesian product before joined tables
// Add these tables as cartesian product before joined tables
$join = implode(', ', array_map('PMA_Util::backquote', $unfinalized));
$first = true;
@@ -1546,6 +1606,7 @@ class PMA_DbQbe
$html_output .= '<table class="data" style="width: 100%;">';
// Get table's <tr> elements
$html_output .= $this->_getColumnNamesRow();
$html_output .= $this->_getColumnAliasRow();
$html_output .= $this->_getShowRow();
$html_output .= $this->_getSortRow();
$html_output .= $this->_getCriteriaInputboxRow();