I have said many times that using Active Record (or ORM, which is almost the same) as business models is not a good idea. Let me explain:
The fact that PHP is Open Source, Free (and this whole long story ...) provides it with an extensive community of developers laying code on forums, sites like GitHub, Google code, etc. You might see it as good, but sometimes it is not so "good." For example, suppose you are facing a project and want to use the ORM structure to solve your problem written in PHP, well ... you will have many options for :
- Doctrine
- Propel
- QCodo
- numbness
- Redbean
And the list goes on and on. New projects are created regularly. Imagine that you have built a full-blown structure and even a source code generator based on this structure. But you did not post business classes, because, in the end, "why write the same classes again?" Time goes by and a new ORM structure is released and you want to switch to a new ORM, but you will have to modify almost all client applications using a direct link to your data model.
The bottom line, active record and ORM are for the data level of your application, if you mix them with your presentation level, you may run into problems like this example that I just put.
Listen to @Mendelt wise words: Read Martin Fowler. He has contributed many books and articles on the design of OO and published some good material on this subject. In addition, you can look at Anti-Patterns , more specifically in the Lock In Provider , what happens when we make our application dependent on third-party tools. Finally, I wrote this blog post talking about the same issue, so check it out if you want.
Hope my answer was helpful.
David conde
source share