Hi all,
I'm new of fuel, and code igniter too, but I'm quite expert about mysql management, and following your tutorials I'm developing my first CMS as well.
I have a question about the multi list. Following your tutorials
http://www.getfuelcms.com/user_guide/modules/tutorialI'm trying to create a multiple choice select, because I need to add a field to the table models form to allow me to associate one or more songs to a setlist's gig. Your example about "Associating Categories to Articles" fit to me, except that I need to keep the record in the right order.
I get the array from the table with:
$songs_setlist = (!empty($values['id_gig'])) ? ($CI->songs_to_gigs_model->find_all_array_assoc('id_song', array('id_gig' => $values['id_gig']),"")) : array();
In my song_to_gig_model I have a method _common_query like the following:
$this->db->select('tbl_songs_gigs.*, tbl_songs.name_song');
$this->db->join('tbl_gigs', 'tbl_songs_gigs.id_gig = tbl_gigs.id_gig', 'left');
$this->db->join('tbl_songs', 'tbl_songs_gigs.id_song = tbl_songs.id_song', 'left');
$this->db->order_by('tbl_songs_gigs.number_song','ASC');
It seems that the songs in my tbl_song_gigs aren't sorted in the right order, which is the field "number_song".
Can you help me with some tips to solve this problem ?
Thank you
Paolo
Comments
thank you for the answer.
By using $CI->songs_to_gigs_model->debug_query() the query seems correct:
SELECT `tbl_songs_gigs`.*, `tbl_songs`.`name_song` FROM (`tbl_songs_gigs`) LEFT JOIN `tbl_gigs` ON `tbl_songs_gigs`.`id_gig` = `tbl_gigs`.`id_gig` LEFT JOIN `tbl_songs` ON `tbl_songs_gigs`.`id_song` = `tbl_songs`.`id_song` WHERE `tbl_songs_gigs`.`id_gig` = '166' ORDER BY `tbl_songs_gigs`.`number_song` ASC
I also tried to print the associative array $songs_setlist and the array is perfectly sorted (look at the key "number song"):
Array ( [35] => Array ( [id_song_gig] => 995 [id_gig] => 166 [id_song] => 35 [number_song] => 1 [note_song] => [name_song] => Caravan girl ) [9] => Array ( [id_song_gig] => 994 [id_gig] => 166 [id_song] => 9 [number_song] => 2 [note_song] => [name_song] => Believer ) [11] => Array ( [id_song_gig] => 993 [id_gig] => 166 [id_song] => 11 [number_song] => 3 [note_song] => [name_song] => Alive ) )
but the sort in the filled multiselect list is still wrong. Maybe I have to modify something in the javascript assets ?
Paolo