Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 25. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Sorting uses string sort instead of numeric

phpMyEdit General     Sorting uses string sort instead of numeric
Odoslať novú tému   Odpovedať na tému    
 
vmehta211     Založený: 22.11.2007   Príspevky: 5  
Príspevok Zaslal: 2007-11-22 00:13
Návrat hore  Odpovedať s citátom     

Hello,
I have a column type of int(11) and it stores a value (seconds). I use the sql option to recalculate lifetime into days. When I sort this column it sorts by string and not by the original value in the column. So 7.0 is larger then 32.0. This is not correct. I've read through this forum and have Google searched for solutions but could not find anything.
I need the sort to be performed on the original values using a numerical comparisons. Is this possible?


$opts['fdd']['lifetime'] = array(
'name' => 'Lifetime (days)',
'select' => 'T',
'escape' => false,
'sql' => 'CONCAT("<center>",ROUND((lifetime / 60 / 60 / 24), 1),"</center>")',
'maxlen' => 255,
'sort' => true
);

 
vmehta211     Založený: 22.11.2007   Príspevky: 5  
Príspevok Zaslal: 2007-11-22 18:57
Návrat hore  Odpovedať s citátom     

I tried that mask suggesstion. It turned all the values into 00000.. I would like to tell myPhpEdit to use a numerical sort on the decimal value after it is calculated or it should perform the sort on the original value.

 
vmehta211     Založený: 22.11.2007   Príspevky: 5  
Príspevok Zaslal: 2007-11-22 19:46
Návrat hore  Odpovedať s citátom     

Where would I find the call to a sorting function in the class file? I did a search and only found ksort under exec_triggers() and that does not seem like the right place to replace ksort with natcasesort().

 
vmehta211     Založený: 22.11.2007   Príspevky: 5  
Príspevok Zaslal: 2007-11-22 20:01
Návrat hore  Odpovedať s citátom     

Maybe I don't understand how to use the mask option.

If I add 'mask' => '%011d' to the field options, I do not get the desired results. Am I missing something?

I wouldn't be opposed to hacking the class file but I am not sure how to approach this task. If anyone knows where to edit the class file or has another possible solution please post.

Thank you!

 
vmehta211     Založený: 22.11.2007   Príspevky: 5  
Príspevok Zaslal: 2007-11-23 01:10
Návrat hore  Odpovedať s citátom     

I tried '%011s' and it does not seem to add 000s but it also does not sort correctly. 9.0 is still considered larger then 32.0

I'll try any suggestions made on this forum. I read on previous posts and other people had the same problem.

They only needed to change the type of field they were using to some numeric type. I am using int(11) so that shouldn't be a problem.

What other workarounds are there? I tried to concatenate the original numeric value to the beginning of i.e. <hidden val=value</hidden><center>ROUND(value/60/60/24,1)</center> thinking it might allow the string sort to work but it didn't.

Any other suggestions?

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov