sorting - PHP. Zend DB adapter -


there gallery on site, , every picture has own tag. of tags sorting chaotically. want sort them value of field "index" in gallerytagstable.

when it's show chaotically code was:

foreach ($_tags $item) {     $select = new select();     $tags[] = $this->getgallerytagstable()->fetchall($select->where(array('id' => $item))); } 

to make sorting field "index", created field , wrote code:

foreach ($_tags $item) {     $select = new select();     $tags[] = $this->getgallerytagstable()->fetchall($select->where(array('id' => $item))->order('index desc')); } 

but still doesn't work. tried write without 'desc' & tried sort 'id'. none of these work.

supposing select() object kind of extended object of zend_db_select, think not working expected because that's not correct syntax clause. correct 1 be:

$select->where('id = ?', $item)        ->order('index desc'); 

note '?' wildcard on expression. made in case don't want equals greater than, or other comparison clauses such rlike. , please, note it's not array.

probably clause wasn't working intended , causing problems on order of tags since not grouped id.

i hope helps.


Comments