![]() |
creating objects - 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: creating objects (/showthread.php?tid=22762) |
creating objects - El Forum - 09-19-2009 [eluser]timaksu[/eluser] hey guys. when i go to save a post to my database, in the controller i do this: Code: $post->title = "title"; from which point the model does the rest however, i want to create an actual post object rather than what im doing above...an object with a constructor etc. Code: $post = new Post(); etc. now i dont need to know how to write up all this..what i want to know is where would i actually place the code for this class? i need this class accessible everywhere ofcourse..so where? creating objects - El Forum - 09-21-2009 [eluser]timaksu[/eluser] bump..still have no idea where to place the code for custom object classes creating objects - El Forum - 09-21-2009 [eluser]überfuzz[/eluser] Not really an answer to you question but anyway. Are you using CI? If yes: Have you ever considered using active records? creating objects - El Forum - 09-21-2009 [eluser]wiredesignz[/eluser] The code for your own classes can be placed in application/libraries or application/plugins directories. Both types can be loaded as needed by your application but note that library classes are instantiated by CodeIgniter after loading and plugin classes are not. creating objects - El Forum - 09-21-2009 [eluser]kurucu[/eluser] As well as the active record class, it would be worth you looking up DMZ (which I have started pronouncing Dee Em Zee in my head, despite being English). It seems like it might save you some time. |