Pass Database as a GET parameter instead of session variable

Issue #242 resolved
Christopher Kramer created an issue

Originally reported on Google Code with ID 242

Currently, we pass the database name as a session variable.
The main reason why I think this is not good is that you cannot have two tabs/windows
of phpLiteAdmin open at the same time (in the same browser) with two different databases.
I think we should pass the DB name as a GET parameter.

Reported by crazy4chrissi on 2014-01-04 19:22:52

Comments (7)

  1. dreadnaut
    Just an idea to help in this direction: some kind of URL 'renderer' that accepts an
    associative array and builds the matching GET string. Something along these lines:
    
    $params = new SmartParams( array( 'currentDB' => $_GET['currentDB'], ... ) );
    $params->sort = 'ASC';
    // ...
    
    $params->getString( array('table' => 'some_table', 'sort' => 'DESC') );
    // produces '?currentDB=...&table=some_table&sort=DESC'
    $params->getHTML( array('table' => 'some_table', 'sort' => 'DESC') );
    // produces '?currentDB=...&table=some_table&sort=DESC'
    
    It would also cut down on the 100+ occurrences of urlencode and & :)
    

    Reported by dreadnaut on 2014-05-30 09:00:23

  2. Christopher Kramer reporter
    Yes, agreed. Maybe we should differentiate between 2 kinds of parameters:
    1. Kind of "state" parameters, that are in _every_ link like currentDB and table. We
    probably set these once and not every time we create a link.
    2. The parameters that are changed in this link. This can be "table" when switching
    the table, but usually it is some parameter that triggers an action or something. These
    parameters are adjusted for every link.
    
    $params= new SmartParams();
    // add parameters that are used for all links
    $params->add('table'=>'mytable');
    $params->add('currentDB'=>'mydb');
    
    //when building a link
    $params->getHTML(array('sort'=>'DESC'));
    // produces '?currentDB=mydb&table=mytable&sort=DESC'
    $params->getHTML(array('table'=>'mytable2'));
    // produces '?currentDB=mydb&table=mytable2'
    
    I think it is stupid to add stuff like table and currentDB every time we create a link.
    It is very likely that at some point, we forget something otherwise.
    

    Reported by crazy4chrissi on 2014-05-30 09:17:23

  3. dreadnaut
    Some short code implementing the above. 'SmartParams' doesn't have to be the name by
    the way, we could come up with something better :-p
    

    Reported by dreadnaut on 2014-06-12 13:47:25

    <hr> * Attachment: SmartParams.php

  4. Log in to comment