Exemplo n.º 1
0
/**
 * Function to set a column property
 *
 * @param PMA_Table $pmatable      PMA_Table instance
 * @param string    $request_index col_order|col_visib
 *
 * @return boolean $retval
 */
function PMA_setColumnProperty($pmatable, $request_index)
{
    $property_value = explode(',', $_REQUEST[$request_index]);
    switch ($request_index) {
        case 'col_order':
            $property_to_set = PMA_Table::PROP_COLUMN_ORDER;
            break;
        case 'col_visib':
            $property_to_set = PMA_Table::PROP_COLUMN_VISIB;
            break;
        default:
            $property_to_set = '';
    }
    $retval = $pmatable->setUiProp($property_to_set, $property_value, $_REQUEST['table_create_time']);
    if (gettype($retval) != 'boolean') {
        $response = PMA_Response::getInstance();
        $response->isSuccess(false);
        $response->addJSON('message', $retval->getString());
        exit;
    }
    return $retval;
}
Exemplo n.º 2
0
 /**
  * Test for setUiProp
  *
  * @return void
  */
 public function testSetUiProp()
 {
     $table_name = 'PMA_BookMark';
     $db = 'PMA';
     $table = new PMA_Table($table_name, $db);
     $property = PMA_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);
 }
Exemplo n.º 3
0
/**
 * Handle remembered sorting order, only for single table query
 *
 * @param string $db              database name
 * @param string $table           table name
 * @param array  &$analyzed_sql   the analyzed query
 * @param string &$full_sql_query SQL query
 *
 * @return void
 */
function PMA_handleSortOrder($db, $table, &$analyzed_sql, &$full_sql_query)
{
    $pmatable = new PMA_Table($table, $db);
    if (empty($analyzed_sql[0]['order_by_clause'])) {
        $sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN);
        if ($sorted_col) {
            // retrieve the remembered sorting order for current table
            $sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
            $full_sql_query = $analyzed_sql[0]['section_before_limit'] . $sql_order_to_append . $analyzed_sql[0]['limit_clause'] . ' ' . $analyzed_sql[0]['section_after_limit'];
            // update the $analyzed_sql
            $analyzed_sql[0]['section_before_limit'] .= $sql_order_to_append;
            $analyzed_sql[0]['order_by_clause'] = $sorted_col;
        }
    } else {
        // store the remembered table into session
        $pmatable->setUiProp(PMA_Table::PROP_SORTED_COLUMN, $analyzed_sql[0]['order_by_clause']);
    }
}
Exemplo n.º 4
0
    $pmatable = new PMA_Table($table, $db);
    if (empty($analyzed_sql[0]['order_by_clause'])) {
        $sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN);
        if ($sorted_col) {
            // retrieve the remembered sorting order for current table
            $sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
            $full_sql_query = $analyzed_sql[0]['section_before_limit'] . $sql_order_to_append
                . $analyzed_sql[0]['limit_clause'] . ' ' . $analyzed_sql[0]['section_after_limit'];

            // update the $analyzed_sql
            $analyzed_sql[0]['section_before_limit'] .= $sql_order_to_append;
            $analyzed_sql[0]['order_by_clause'] = $sorted_col;
        }
    } else {
        // store the remembered table into session
        $pmatable->setUiProp(PMA_Table::PROP_SORTED_COLUMN, $analyzed_sql[0]['order_by_clause']);
    }
}

// Do append a "LIMIT" clause?
if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
    && ! ($is_count || $is_export || $is_func || $is_analyse)
    && isset($analyzed_sql[0]['queryflags']['select_from'])
    && ! isset($analyzed_sql[0]['queryflags']['offset'])
    && empty($analyzed_sql[0]['limit_clause'])
) {
    $sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos']
        . ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";

    $full_sql_query  = $analyzed_sql[0]['section_before_limit'] . "\n"
        . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
Exemplo n.º 5
0
/**
 * Function to set the column visibility
 *
 * @param PMA_Table $pmatable PMA_Table instance
 *
 * @return boolean $retval
 */
function PMA_setColumnVisibility($pmatable)
{
    $col_visib = explode(',', $_REQUEST['col_visib']);
    $retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_VISIB, $col_visib, $_REQUEST['table_create_time']);
    if (gettype($retval) != 'boolean') {
        $response = PMA_Response::getInstance();
        $response->isSuccess(false);
        $response->addJSON('message', $retval->getString());
        exit;
    }
    return $retval;
}