Advanced OOP With SPL In PHP 5
Implementing The IDataBaseBindings Interface
To implement the above class create a new file called PostgreSQL.php. Its contents will look something like this:
Listing 2 PostgreSQL.php
/** * PostgreSQL implementer for IDataBaseBindings. * * Implements all members indicated by the interface and * optimizes queries for the PostgreSQL database. * * @author Kevin McArthur * @depends UnbufferedAssociativeResultSet, IDataBaseBindings * @implements IDataBaseBindings */ class PostgreSQL implements IDataBaseBindings { public function __construct() { // Create Database Connections } /** * getCustomerDetails * * Gets customer data from userDetails specified by userid * * @see IDatabaseBindings */ public function getCustomerDetails($userid) { $queryResult = pg_query('select * from userDetails where userid = '. $userid . ';'); return new UnbufferedAssociativeResultSet($queryResult); } public function __destruct() { // Destroy Database Connections } }
The above code creates a new class called PostgreSQL that implements the getCustomerDetails() method.
This method should be responsible for doing all queries and not have any database unspecific logic. Simply retrieving or setting values in the database directly.




