[Phpmyadmin-devel] Column reordering

Marc Delisle marc at infomarc.info
Tue Jun 14 13:55:57 CEST 2011


Aris Feryanto a écrit :
> 
> ----- Original Message -----
>> From: Marc Delisle <marc at infomarc.info>
>>
>> Marc Delisle a écrit :
>>>   Aris Feryanto a écrit :
>>>
>>>>   Hi,
>>>>
>>>>   Just realized my previous email seem not delivered successfully to
>>>>   phpMyAdmin-devel list. I've previously sent an email telling that I
>>>>   will work on merging the tooltip as suggested by Rouslan. I'm still
>>>>   working and testing on this and will add the 'Click to mark'.
>>>>
>>>>   I am also fixing the previous code, as it hasn't checked whether we
>>>>   are under Browse tab, before calling the column-order remembering
>>>>   function.
>>>>
>>>>   I wonder if there is any existing exact way to check if we are under
>>>>   Browse tab? Current code do the checking using requested url pattern
>>>>   and analyzed SQL query (you may see function PMA_isBrowsing in file
>>>>   libraries/display_tbl.lib.php in my git repo). But, this is not
>>>>   enough for handling load from AJAX request under other tabs (e.g.
>>>>   AJAX request to sql.php caused by pagination of results under SQL
>>>>   tab)
>>>   Yes, this is difficult to solve with current code; maybe it's time for 
>> a
>>>   new tbl_browse.php that could set some constant, then require sql.php.
>>>   Further down the code, either the constant is checked directly or is
>>>   used to generate a hidden span with some id that can be checked at the
>>>   js level.
>>>
>>>
>> By the way, I'm not sure why you strictly want to do some verifications
>> while under the Browse tab. Some actions, for example Search, will
>> generate results in which in a user might want to reorder the columns.
> 
> 
> Hi Marc,
> 
> You are right. User may want to reorder columns in Search tab.
> 
> I found a way to make PMA_isBrowsing() better, IMO. I add some rule so that it will return true on any SQL expression in the form of "SELECT * FROM <a table> WHERE ...". Not depending on whether we are under "Browse" tab anymore. I've updated this in my git. The complete function:
> 
> ===========================
> function PMA_isBrowsing()
> {
>     // global variables set from sql.php
>     global $is_count, $is_export, $is_func, $is_analyse;
>     global $analyzed_sql;
> 
>     return ! ($is_count || $is_export || $is_func || $is_analyse)
>         && count($analyzed_sql[0]['select_expr']) == 0
>         && isset($analyzed_sql[0]['queryflags']['select_from'])
>         && count($analyzed_sql[0]['table_ref']) == 1;
> }
> ===========================
> 
> I've do some test and it is working good so far. Please kindly check this and let me know what do you think about this.

Aris,
Looks fine but I suggest naming this PMA_isSelect() and changing the 
function's comment.

Two other things.

1. I get a notice when browsing sakila.actor. I'm not sure when this 
notice started to show but here it is:

Notice in ./libraries/display_tbl.lib.php#492
Undefined index: 14b4d4f7c160f209e980cfb221bb3117

Backtrace

./libraries/display_tbl.lib.php#2255: PMA_displayTableHeaders(
array,
array,
integer 4,
array,
string `actor`.`first_name` DESC,
string `actor`.`first_name`,
string DESC,
)
./sql.php#925: PMA_displayTable(
object,
string urdr111111,
array,
)

2. "Restore column order" is not persistent. After restoring and 
clicking anything (next, end, Browse), the modified column order comes back.

-- 
Marc Delisle
http://infomarc.info




More information about the Developers mailing list