Welcome Guest, Not a member yet? Register   Sign In
How to use codeigniter and real OOP?
#1

[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
#2

[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
#3

[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
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB