/** * 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')); } }
/** * Get column order and column visibility * * @param array $analyzed_sql_results analyzed sql results * * @return array 2 element array - $col_order, $col_visib * * @access private * * @see _getTableBody() */ private function _getColumnParams($analyzed_sql_results) { if ($this->_isSelect($analyzed_sql_results)) { $pmatable = new Table($this->__get('table'), $this->__get('db')); $col_order = $pmatable->getUiProp(Table::PROP_COLUMN_ORDER); $col_visib = $pmatable->getUiProp(Table::PROP_COLUMN_VISIB); } else { $col_order = false; $col_visib = false; } return array($col_order, $col_visib); }
/** * Test for setUiProp * * @return void */ public function testSetUiProp() { $table_name = 'PMA_BookMark'; $db = 'PMA'; $table = new Table($table_name, $db); $property = Table::PROP_COLUMN_ORDER; $value = "UiProp_value"; $table_create_time = null; $table->setUiProp($property, $value, $table_create_time); //set UI prop successfully $this->assertEquals($value, $table->uiprefs[$property]); //removeUiProp $table->removeUiProp($property); $is_define_property = isset($table->uiprefs[$property]) ? true : false; $this->assertEquals(false, $is_define_property); //getUiProp after removeUiProp $is_define_property = $table->getUiProp($property); $this->assertEquals(false, $is_define_property); }