Pierre Minnieur | 16 May 17:04
Picon
Gravatar

[phpdba] DBAL definition

Hi,
 
I have some questions regarding the terms from the DBAL world, respective their roles, meanings and essentials in PHP. What I want to know is what's essential for a DBAL and what's useless and should be implemented elsewhere, because it has nothing to do with an abstraction layer or it is better abrogated elsewhere.
 
DBAL - Database Abstraction Layer:
 
Description:
A database abstraction layer provides a common API to access data located in a RDBMS.
 
 
Meaning:
  1. A common API for connecting and disconnecting to a RDBMS.
    We don't have to remember how mysqli can connect to a server, neither how PDO connections are established.
  2. A common API for sending queries to the database.
    This may include implementations for the different kinds of queries, e.g. SELECT, INSERT, UPDATE, DELETE to provide later usage of the results (e.g. return the last inserted id, the number of affected rows or the result set).
  3. A common API for transaction handling.
    Methods to begin, commit and rollback a transaction, including nested transactions.
  4. Features/Quoting/Wildcards/etc
    A list of features the connected RDBMS supports, e.g. if auto_increment or sequences are supported, how table/field names and their values have to be quoted/escaped, which wildcards can be used for several query operations (e.g. MySQL's LIKE) and so on. They could be used by other components to build queries.
  5. Primary Key handling (auto_increment/sequences)
    Some kind of an ID generator like Creole has, so we can easily handle IDs without knowing which mechanism is used by the RDBMS.
  6. Charset conversation.
    Ensures that the charset used is always correct and no wrong encoded data will find its way into the database.

Don'ts:

  • Field type conversation. Any piece of data is handled as it is delivired by the RDBMS.
  • Query builder. A DBAL only accepts plain text (strings) which will be send to the RDBMS directly.
  • RDBMS specific query syntax checking. The queries will be executed as provided.
I'd appreciate if you would correct me if I understand anything wrong, if you have suggestions or if something is missing in that definition.
 
Regards,
Pierre

Gmane