On Apr 30, 2013, at 6:51 PM, Amy Stephen <
amyst...@gmail.com> wrote:
> Lots of good work out there in the database area:
> • Each of these packages, with the exception of one, have Interfaces that position for use in other projects.
> • Each of these packages, with the exception of two, are already offered on Packagist.
> • Each of these packages *heavily* rely upon PDO.
> • None of these packages are small, there is considerable code, even with PDO's advancements.
> The challenge to interoperability is that none of these packages have exactly the same Interface.
>
> That means application code changes are required to use the ZF2 database package instead of the Aura database package, and visa versa.
>
> The good thing is that in reviewing the interfaces, it's clear the differences are minor and reconcilable.
>
> A common interface, implemented using an adapter pattern and database handlers makes these packages interoperable from an application standpoint. To use another package that is more performant, or required by my client, is simple with that type of architecture -- I just add the package to composer.json and update. No other work is needed.
>
> That's interoperability! And, yes, it would be just like the accomplishments of the logger interface. =)
We need to avoid creating another ORM. Propel and Doctrine fill that space, and they do it quite well. Not to mention that these projects have been at it for years. It will be very hard to create something that's both minimal, and useful and actually picked up by anyone.
The reason existing database layers are not identical, is because they have different design goals and ideas how this should be approached. If these ideas were identical, there would not be a real need for alternatives.
I also feel that any PSR should be simple and to the point. Creating something that abstracts SQL syntax by creating a new syntax (such as doctrine's DQL) or through an OOP interface is a massive project, and would in the end just create another competitor. I doubt that ay member projects would be interested in pursuing such a massive venture, I have, at the very least, not yet heard positive feedback of that nature.
So given that, and assuming I'm right, what would be a good choice for a common interface for database access? In my mind this would just be the absolute basics (prepare, query, quote) and we have a way to do that: PDO.
So any projects that don't want to depend on 1 ORM, can allow consumers to inject an instance of PDO. All you really need then is a way for the existing ORM's to get a hold of the underlying PDO object, and you've basically solved your problem.
So yea, I believe that this should not be solved as a PSR, it should be solved as an external package (Doctrine, Propel or something new), or not at all (and just stick to PDO).
But, if you don't buy my argument... I would say... rather than thinking about this on a conceptual level, try thinking about what it would actually take to write this.. Write the interface, do a couple of implementations and see if you can come up with something that's both useful and simple.
At the very least that will give us something realistic to debate for it's usefulness and whether projects would be interested in picking it up.
Evert