Custom ORM - Suggestions |
Hello,
I switched from Laravel to CodeIgniter, I really like simplicity" and freedom that CI brings. Since I only miss Eloquent in CodeIgniter I started working on my own. My plan isn't something advanced, I want to have relationships and some methods like isSomething(). How it works: In models I have methods like all(), find($id)... In those methods are $this->db queries. Also, I have Entities. You can see that I run foreach in all() method and there I create Entity instances. I really like this because I can have relationships or some methods that I can access everytime without writing new queries. For example, I have method isPublic() that checks if column "access_level" isn't set to "private". There should be something like BaseEntity class or interface that each Entity will extend/use but this is just a prototype. The one thing that really annoys me is this "require_once" call at the top. Is there a better way to load those classes? I would like to know what do you think about this and what should be improved Thanks. I appreciate any suggestions. (sorry if I posted in a wrong subforum) Controller: PHP Code: <?php Model: PHP Code: <?php Entity: PHP Code: <?php
This sounds a bit like https://codeigniter4.github.io/CodeIgnit...eling-data, no?
I haven't checked that link so far. It's definitely what I want to have on my CI 3 project.
That link is for CI4, definitely not compatible with CI3 ... could be a reason to look at migrating to the new version
I didn't express myself correctly in the last post, CI4 Entities are the best example of what I want to build for my CI3 project.
I will consider CI4 for new projects but for now I will continue to work on this. |
Welcome Guest, Not a member yet? Register Sign In |