karsumit94 / phpliteadmin

Automatically exported from code.google.com/p/phpliteadmin
0 stars 0 forks source link

Pass Database as a GET parameter instead of session variable #242

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by crazy4ch...@gmail.com on 4 Jan 2014 at 7:22

GoogleCodeExporter commented 9 years ago

Original comment by crazy4ch...@gmail.com on 22 May 2014 at 8:58

GoogleCodeExporter commented 9 years ago
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 & :)

Original comment by dreadnaut on 30 May 2014 at 9:00

GoogleCodeExporter commented 9 years ago
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.

Original comment by crazy4ch...@gmail.com on 30 May 2014 at 9:17

GoogleCodeExporter commented 9 years ago
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

Original comment by dreadnaut on 12 Jun 2014 at 1:47

Attachments: