I’ve been working with Doctrine 2 ORM for some time, and there’s something I’ve never quite understood.
What purpose does the Doctrine DBAL (database abstraction layer) serve? PDO itself a database abstraction layer, so why can’t the ORM work directly with PDO?
I’m not trying to find a way around using DBAL or anything. I’ve just never understood why the extra layer is needed, and can’t seem to find a clear answer in the documentation.
No, PDO is a “data-access layer”, not a “database abstraction layer”. Meaning that you can switch databases and still make the same method calls, but PDO will not re-write sql queries to match the selected database or emulate any database functionality.
Per PHP PDO docs: