second query based on first query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: second query based on first query (/showthread.php?tid=56400) |
second query based on first query - El Forum - 12-16-2012 [eluser]sniperscope[/eluser] Hello All seems i am going to be a permenant visitor of this form. I have some problem which i want to create a inner query based on outer query My previous Sql query was below and i want to know how can i make it run in CI Regards Code: $sql_price_master = mysql_query("SELECT price_id, price_name, price_remark FROM price_master ORDER BY price_id ASC"); second query based on first query - El Forum - 12-17-2012 [eluser]sniperscope[/eluser] I solved my problem. I am posting solution and hope it might help to someone else too. Code: class Model_System extends CI_Model second query based on first query - El Forum - 12-21-2012 [eluser]vitoco[/eluser] Just FYI , the idea of MVC it's to separate the data retrieving ( logic ) from their presentation, so it's good that you run the database queries inside the model, but not to create the html code( a table in this case ) in the same function, just retrieve the data to the controller, and then pass that data to the view. In the long run ( not so long really ) it will be a mess if you combine both in the same code. |