Help converting a function to CI - 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: Help converting a function to CI (/showthread.php?tid=15340) |
Help converting a function to CI - El Forum - 02-01-2009 [eluser]macleodjb[/eluser] Hi guys, I'm a little shaky with how i need to code this function now that i am using codeigniter, before i had a functions file which i would just include into the file i needed it in and just echo out what i needed at any time. The function below is my old function and it would be placed into job_model.php. The functions its calling are functions that reside in Main_model.php. Obviously i'm getting an error with Main_model. Don't really know why, perhaps you can help. Code: function populate_subcat_array() { Help converting a function to CI - El Forum - 02-01-2009 [eluser]JaRoLLz[/eluser] CI use MVC. So, you should separate your app into model, view, controller. As for that function, you should split it into M,V,C. [model] In job_model, create a function to get the `cats` data then return an array that contains its data [view] in a view file (e.g. subcat.php), create a layout to present the data [controller] in your controller (e.g. Cats) create a function that will get data using the model then passing it to view file to show. crude example: MODEL: job_model.php Code: class Job_model extends Model { VIEW: subcat.php Code: <html> CONTROLLER: cats.php Code: class Cats extends Controller { p.s.: Adjust the code as needed. CMIIW! |