SQL Data Access API: SQL Databases Support Driver

This API wraps PDO native library in order to overcome latter's poor design (eg: lack of data source encapsulation) and build a flexible object oriented structure on top of it.

How does it work?

The purpose of refactoring PDO functionality isn’t just to overcome PDO design flaws, but also to bring unity and structure to the process of communication with a database server. In light of above observations on PDO library, functionality is divided into following classes:

  1. DataSource: encapsulates data required in connecting to a database server.
  2. Connection: manages connection related operations based on DataSource
  3. Transaction: manages transaction related operations.
  4. Statement: manages statement execution operations.
  5. PreparedStatement: manages statement preparation and execution operations.
  6. StatementResults: manages information to be retrieved following statement execution.

When an error is encountered, exceptions specific to event are thrown:

  1. ConnectionException: thrown when connection to server fails.
  2. StatementException: thrown when statement execution fails.

Almost always we also desire to reuse created connection for other queries throughout user session's duration and also make sure that connection is automatically closed when session ends. For this two classes were added:

  1. ConnectionSingleton: insures a single connection is created, then reused by all queries throughout session's duration, then closed when session ends. This is useful when you're only using one SQL server during session's lifetime.
  2. ConnectionFactory: insures a single connection is created for each server, then reused by all queries on that server throughout session's duration, then closed when session ends. This is useful when you're using more than one SQL server during session's lifetime.

All classes inside API belong to namespace Lucinda\SQL!

How can I use it?

To learn how to install and use this API, follow this step-by-step guide!


Share