Getting an ORM-like object tree

Hey everyone!

I’ve been recently delving into PHP with a few private projects. I’m now at a point where I work with a database that’s a little bigger and a little more complex and find myself needing object trees, something like an ORM would return, for the sake of keeping my class code proper and clean.

I am aware that there are ORM solutions for PHP but there are a few reasons why I unfortunately can’t really use them. I spent some time building a solution that works and am now wondering if any more experienced PHP devs could take a look at it and maybe give me some hints what I could be improving.

My biggest concern right now is performance, I’ve not messed with PHP for too long which is why I’m not exactly sure how much something like what I built could impact the performance of my application.

For the sake of keeping the thread readable the code is provided in this pastebin instead.

ORMs are complicated; you’ve almost certainly got it wrong. Fix whatever is stopping you using an off the shelf ORM, then use one. Failing that, don’t use an ORM at all.

1 Like

You would be much better off telling us the real problem you are trying to solve rather than asking about your attempted solution to solving it.

Sponsor our Newsletter | Privacy Policy | Terms of Service