Is It the Holy Grail?

One very legitimate concern might be voiced over the inclusion of the SQLite-specific method sqliteCreateFunction, and this is certainly not the only database-specific capability provided by PDO.3 Doesn't providing database-specific functionality do exactly what we refrained from doing at the start— namely, extending the PDO class?

The short answer is, unquestionably, yes. But the whole notion of a perfect database abstraction layer is a Holy Grail—glimpsed here and there but never grasped. Providing some database-specific functionality is a sensible compromise and an impetus to use PDO. As always with PHP, utility and not purity of concept is paramount. The important thing to note is that each developer can make their own decision about an acceptable level of database abstraction by incorporating database-specific methods and database-specific SQL or not as the case may be. However, in one respect there's no choice at all: If you choose to use PDO, you must take an OO approach.

3 The constant PDO: :MYSQL_ATTR_USE_BUFFERED_QUERY can be used to create a buffered result set with a MySQL database. Using fetchAll is the more abstract or database-neutral approach.

0 0

Post a comment

  • Receive news updates via email from this site