Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Pondelok, 30. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Alphabetize a multiple select list?

phpMyEdit Configuration     Alphabetize a multiple select list?
Odoslať novú tému   Odpovedať na tému    
 
michal     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2003-11-19 22:36
Návrat hore  Odpovedať s citátom     

http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.input-restrictions.html

see

$opts['fdd']['col_name']['values']['orderby'] = 'last_name'; // optional ORDER BY clause

 
michal     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2003-11-21 03:40
Návrat hore  Odpovedať s citátom     

looking at your code, i cannot understand how this dropdown box takes effect :) basically you should make use of valuse/values2 option or values option for table joining. both of these make dropdown boxes for add, change and filter option.

1. you manually enter new possible values in the values2 option. whith this you can order this array with a php function before you enter it as values2 option

2. you have the values option defined as a table join. meaning you have defined table, id, ... in the values option. whith this you can use the mentioned order by clause. i think the documentation is done very well for this option

which option do you want to use ?

 
paolodp     Založený: 06.07.2006   Príspevky: 11  
Príspevok Zaslal: 2006-08-17 17:04
Návrat hore  Odpovedať s citátom     

hi,

I have a dropdown list with table lookup:

Kód:

$opts['fdd']['IdEquipe'] = array(
  'name'     => 'Chef d\'équipe',
  'select'   => 'D',
  'options'  => 'AVCPD',
  'maxlen'   => 11,
  'default'  => '0',
  'nowrap'     => true,
  'sort'     => true
);

$opts['fdd']['IdEquipe']['values']['table']='Agents';
$opts['fdd']['IdEquipe']['values']['column']='Id';
$opts['fdd']['IdEquipe']['values']['description']='Nom';
$opts['fdd']['IdEquipe']['values']['orderby']='Nom';
$opts['fdd']['IdEquipe']['values']['filters']='True';


First I used this code without orderby and worked fine, sorting by Nom the dropdown choices.
Suddenly, without changements, it begun to sort by Id.

I added lines orderby and filters after, but it does not work anyway:

The dropdown lists options by Id and not by Nom.

Anybody has an idea ?

I thought it happens because I have field Nom in primary table too but there is a post about ambiguous names that says there'd not be problem in this case

Should it depends of server settings changes ?

 
valedo     Založený: 31.08.2006   Príspevky: 6   Bydlisko: Ukraine
Príspevok Zaslal: 2006-09-02 08:53
Návrat hore  Odpovedať s citátom     

I have this problem too with $opts['fdd']['col_name']['values']['orderby']!

See http://opensource.platon.sk/forum/projects/viewtopic.php?t=893


Naposledy upravil valedo dňa 2006-09-07 06:33, celkom upravené 1 krát

 
paolodp     Založený: 06.07.2006   Príspevky: 11  
Príspevok Zaslal: 2006-09-03 15:25
Návrat hore  Odpovedať s citátom     

hi,

link reported by Valedo shows a mysql bug with a select query: when DISTINCT keyword is used, ORDER BY fails.

I tried to add groupby with no result; so I found this solution:I hacked phpMyEdit.class.php and remove DISTINCT from the query builder (line 377):
Kód:

//$qparts['select'] = 'DISTINCT '.$table.'.'.$key;
$qparts['select'] = $table.'.'.$key;


This is ok as long as you dont need using DISTINCT in your queries.

 
valedo     Založený: 31.08.2006   Príspevky: 6   Bydlisko: Ukraine
Príspevok Zaslal: 2006-09-03 15:34
Návrat hore  Odpovedať s citátom     

what do you think about my solution with "GROUP BY"?

paolodp Napísal:
hi,

link reported by Valedo shows a mysql bug with a select query: when DISTINCT keyword is used, ORDER BY fails.

I tried to add groupby with no result; so I found this solution:I hacked phpMyEdit.class.php and remove DISTINCT from the query builder (line 377):
Kód:

//$qparts['select'] = 'DISTINCT '.$table.'.'.$key;
$qparts['select'] = $table.'.'.$key;


This is ok as long as you dont need using DISTINCT in your queries.


 
paolodp     Založený: 06.07.2006   Príspevky: 11  
Príspevok Zaslal: 2006-09-06 16:07
Návrat hore  Odpovedať s citátom     

hi Valedo

before my hack solution, I tried to use solution that you posted adding ['values']['groupby'] definition, but did not work for me.

Perhaps I did not understand your solution, as you wrote:

Kód:

In any case i found solution:
Mysql Query must be :
SELECT DISTINCT Articles_categories.category,Articles_categories.id FROM mydb.Articles_categories GROUP BY category ORDER BY category


so I'm not sure that you made this simply adding
['values']['groupby'] definition.

Reading comments about the mysql bug, I found another possible way simpler than hacking phpMyEdit class (but I've not still tested it) to solve the problem: add mysql index on the ordering field. (TO TEST)

 
valedo     Založený: 31.08.2006   Príspevky: 6   Bydlisko: Ukraine
Príspevok Zaslal: 2006-09-07 07:00
Návrat hore  Odpovedať s citátom     

Hi!

You right, it is not enough to add

Citácia:

so I'm not sure that you made this simply adding
['values']['groupby'] definition.


also you need to add a 1 line in class code
Kód:

function set_values_from_table($field_num, $strict = false) /* {{{ */

   {
      $db    = &$this->fdd[$field_num]['values']['db'];
      $table = &$this->fdd[$field_num]['values']['table'];
      $key   = &$this->fdd[$field_num]['values']['column'];
      $desc  = &$this->fdd[$field_num]['values']['description'];
      $dbp   = isset($db) ? "$db." : $this->dbp;
      $qparts['type'] = 'select';
etc...


then you need to find this
Kód:
         if ($this->fdd[$field_num]['values']['orderby']) {
            $qparts['orderby'] = $this->substituteVars($this->fdd[$field_num]['values']['orderby'], $ar);
         }


add here
Kód:
$qparts['groupby'] = $this->substituteVars($this->fdd[$field_num]['values']['orderby'], $ar);


you must get this code
Kód:
+         if ($this->fdd[$field_num]['values']['orderby']) {
+            $qparts['groupby'] = $this->substituteVars($this->fdd[$field_num]['values']['orderby'], $ar);
+            $qparts['orderby'] = $this->substituteVars($this->fdd[$field_num]['values']['orderby'], $ar);
+         }


can you give me an example of you solution ?

 
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