Welcome Guest, Not a member yet? Register   Sign In
How to achieve N-Tier type in Codeigniter MVC
#1

[eluser]ahmed.samy[/eluser]
I know that N-Tier intended to separate layers on different network

but I would like to have the same code separation in codeigniter

I had this idea to have
Model : for database CRUD - > Data layer
REST API : for business logic --> Business layer that calls CRUD method from models

Controller & View are going as before


and flow will be

View<--&gt;Controller <--&gt; API(with Business classes) <--&gt;Model

I wanna know what kind of drawbacks it can be such architecture
#2

[eluser]Harold Villacorte[/eluser]
+1 for this pattern. I find that in a complex application not having a layer between the controller and the model ends up in overly controller heavy code.
#3

[eluser]Aken[/eluser]
I'm not familiar with the N-Tier term, but before I go looking it up, you can always use multiple models for a certain purpose. One model can in turn load another, so the first can do a bunch of business / API logic, while the second performs your DB operations.
#4

[eluser]ahmed.samy[/eluser]
[quote author="Aken" date="1362790270"] One model can in turn load another, so the first can do a bunch of business / API logic, while the second performs your DB operations.[/quote]

So you mean i can create hierarchy of models that call each other,

Data model <---&gt; business logic model <-----&gt; another Data model ....etc ...

isn't that a bad practice for MVC, please correct me if I am wrong
#5

[eluser]TheFuzzy0ne[/eluser]
I don't think it's bad practice. The whole point of MVC is to keep your Models, Views and Controller separate, which you're doing.

What Aken is suggesting, is that you add another layer to your model. One model does your business logic, and calls on any other models required to pull data from the database.




Theme © iAndrew 2016 - Forum software by © MyBB