setUiProp() public method

If pmadb and table_uiprefs is set, it will save the UI preferences to phpMyAdmin database. Available property: - PROP_SORTED_COLUMN - PROP_COLUMN_ORDER - PROP_COLUMN_VISIB
public setUiProp ( string $property, mixed $value, string $table_create_time = null ) : boolean | Message
$property string Property
$value mixed Value for the property
$table_create_time string Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
return boolean | Message
Example #1
0
/**
 * Function to set a column property
 *
 * @param Table  $pmatable      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 = Table::PROP_COLUMN_ORDER;
            break;
        case 'col_visib':
            $property_to_set = 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\libraries\Response::getInstance();
        $response->setRequestStatus(false);
        $response->addJSON('message', $retval->getString());
        exit;
    }
    return $retval;
}
Example #2
0
 /**
  * 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);
 }