It's been a long time since I was first introduced to the concepts of Object-Relational Mapping (ORM). First time I took a deeper look at this subject in ~2004. Since then, my mind has changed, and my perception of ORM has changed either. There was time when I thought that SQL can be practically eliminated from the application, and design patterns like Unit-of-Work echoed with warmth and joy inside my head. Well, this is no more. For the last several years my feelings about ORM stay mostly unchanged, and as such, I want now to summarize my opinion in this post.
The following is mostly related to a typical PHP application that stores data in RDBMS. Such apps usually have a short-living request-response cycle:
↑ HTTP Request
↑ Process particular request (typically involves talking to a database)
Return result to the user
All of this usually takes 10 - 500 ms. The developer usually does not deal with multithreaded environments, in contrast to, f. e. Java. It does not mean there is no concurrency, of course, but that's a different issue: at least you don't have to worry that an object you're working with is being modified at the very same time in a neighboring thread.
The awareness of the short cycle of request-response has largely formed my attitude to ORM in PHP applications. In short: I like ORM but I like it simple. Below are a few points that I have set for myself.