public function getUiProp($property)
{
if (!isset($this->uiprefs)) {
$this->loadUiPrefs();
}
// do checking based on property
if ($property == self::PROP_SORTED_COLUMN) {
if (!isset($this->uiprefs[$property])) {
return false;
}
if (!isset($_REQUEST['discard_remembered_sort'])) {
// check if the column name exists in this table
$tmp = explode(' ', $this->uiprefs[$property]);
$colname = $tmp[0];
//remove backquoting from colname
$colname = str_replace('`', '', $colname);
//get the available column name without backquoting
$avail_columns = $this->getColumns(false);
foreach ($avail_columns as $each_col) {
// check if $each_col ends with $colname
if (substr_compare($each_col, $colname, mb_strlen($each_col) - mb_strlen($colname)) === 0) {
return $this->uiprefs[$property];
}
}
}
// remove the property, since it no longer exists in database
$this->removeUiProp(self::PROP_SORTED_COLUMN);
return false;
}
if ($property == self::PROP_COLUMN_ORDER || $property == self::PROP_COLUMN_VISIB) {
if ($this->isView() || !isset($this->uiprefs[$property])) {
return false;
}
// check if the table has not been modified
if ($this->getStatusInfo('Create_time') == $this->uiprefs['CREATE_TIME']) {
return $this->uiprefs[$property];
}
// remove the property, since the table has been modified
$this->removeUiProp(self::PROP_COLUMN_ORDER);
return false;
}
// default behaviour for other property:
return isset($this->uiprefs[$property]) ? $this->uiprefs[$property] : false;
}
/** * Handle remembered sorting order, only for single table query * * @param string $db database name * @param string $table table name * @param array &$analyzed_sql_results the analyzed query results * @param string &$full_sql_query SQL query * * @return void */ function PMA_handleSortOrder($db, $table, &$analyzed_sql_results, &$full_sql_query) { $pmatable = new Table($table, $db); if (empty($analyzed_sql_results['order'])) { // Retrieving the name of the column we should sort after. $sortCol = $pmatable->getUiProp(Table::PROP_SORTED_COLUMN); if (empty($sortCol)) { return; } // Remove the name of the table from the retrieved field name. $sortCol = str_replace(PMA\libraries\Util::backquote($table) . '.', '', $sortCol); // Create the new query. $full_sql_query = SqlParser\Utils\Query::replaceClause($analyzed_sql_results['statement'], $analyzed_sql_results['parser']->list, 'ORDER BY ' . $sortCol); // TODO: Avoid reparsing the query. $analyzed_sql_results = SqlParser\Utils\Query::getAll($full_sql_query); } else { // Store the remembered table into session. $pmatable->setUiProp(Table::PROP_SORTED_COLUMN, SqlParser\Utils\Query::getClause($analyzed_sql_results['statement'], $analyzed_sql_results['parser']->list, 'ORDER BY')); } }