CodeIgniter Forums
How to use codeigniter and real OOP? - 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: How to use codeigniter and real OOP? (/showthread.php?tid=35208)



How to use codeigniter and real OOP? - El Forum - 10-22-2010

[eluser]Sinclair[/eluser]
Hi,

I'm starting a new application using CI, but I want to create this application using real OOP and MVC at the same time.

For example, in this application I will have Employees. In which place can I define the class Employees? In the application\libraries?

There are some docs that I can read that can help me?

Best Regards


How to use codeigniter and real OOP? - El Forum - 10-22-2010

[eluser]LuckyFella73[/eluser]
Quote:For example, in this application I will have Employees. In which place can I define the class Employees? In the application\libraries?

It depends what your class is suppose to do (more or less). If your class is interacting
with the database you would save it as a model and save it to "application/models"
otherwise it should go to "application/libraries"

To learn OOP stuff you could start at:
http://php.net/manual/en/language.oop5.basic.php


How to use codeigniter and real OOP? - El Forum - 10-22-2010

[eluser]Phil Sturgeon[/eluser]
CodeIgniter libraries and models use the Singleton pattern, but of course you can still do this.

Model

Code:
class Employee {}

Controller

Code:
$this->load->model('employee');

$foo = new Employee;

It's only PHP remember Smile


How to use codeigniter and real OOP? - El Forum - 06-11-2011

[eluser]EmnaKhemiri[/eluser]
Employee management and lone worker protection and solutions - health and safety UK - http://www.loneworkersystems.co.uk