Newbie question : How to specify relationship between tables ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Newbie question : How to specify relationship between tables ? (/showthread.php?tid=3149) |
Newbie question : How to specify relationship between tables ? - El Forum - 09-12-2007 [eluser]Unknown[/eluser] Hello, Sorry to ask a so stupid question but ... :-) I have to tables : Country : id country_name Wine : id wine_name country I want to have a drop down list when i add a new wine in my database with all the countries. Can someone help me ? Thanks. Dominique. Newbie question : How to specify relationship between tables ? - El Forum - 09-12-2007 [eluser]zdknudsen[/eluser] This is one of the things CodeIgniter does not do for you. You'll have to do this yourself using the database library. Newbie question : How to specify relationship between tables ? - El Forum - 09-12-2007 [eluser]Michael Wales[/eluser] Pretty simple (not as easy as Ruby on Rails, which virtually does it automagically), but simple nonetheless. From your controller's method, make a query to select all of the country names, dump that into an array, pass it to your view, and then either use the form_dropdown() form helper or foreach() through it using your own XHTML select tag. Newbie question : How to specify relationship between tables ? - El Forum - 09-12-2007 [eluser]Unknown[/eluser] You are really fast to answer ! ;-) I was asking this question because i was trying just before cakephp. Thanks for your answers. I'm going to try. Dominique. |