Thanks for the feedback...
Hopefully, this can get you started in the right direction.
DB Platform-specific adapters all reside in /includes/qcodo/database_adapters. As you can see, only two adapters exist so far... MySql and MySqli (the MySqli utilizes the “MySQL Improved” extension, while the MySQL utilizes the older MySQL extension).
Database adapters consist of 7 classes which extend from the DatabaseBase classes (/includes/qcodo/framework_objects). Don't let that “7” number scare you... only one of those classes actually has code. The other 6 are practically empty:
* DatabaseBase
(so your new adapter would have a class called PostgreSqlDatabase, which extends DatabaseBase)
* DatabaseForeignKeyBase (PostgreSqlDatabaseForeignKey)
* DatabaseIndexBase (PostgreSqlDatabaseIndex)
* DatabaseFieldBase (PostgreSqlDatabaseField)
* DatabaseResultBase (PostgreSqlDatabaseResult)
* DatabaseRowBase (PostgreSqlDatabaseRow)
* DatabaseExceptionBase (PostgreSqlDatabaseExtension)
So the DatabaseBase class (or in your case, the PostgreSqlDatabase class) basically is a wrapper around the PostgreSql extension. In fact, you should feel free to say that the class has protected member variable $objDbConnection which would store the resource returned by pg_connect. And then any of the class to PostgreSqlDatabase->Query or >FetchArray or whatever, are simply calls to the appropriate pg_* method (passing in $this>objDbConnection as as the resource).
PostgreSqlDatabase will need to implement the following methods:
// This connects to the database, reading in DBCONFIG_#_xxx constants
// where # is the $intDatabaseIndex that's passed in
abstract public function __construct($intDatabaseIndex);
// Query is just to query given a sql string. No query is for queries
// the don't actually return a result (e.g. DELETE, UPDATE, INSERT).
// QuerySet is not really implemented yet.
abstract public function Query($strQuery);
abstract public function QuerySet($strQueries);
abstract public function NonQuery($strNonQuery);
// GetTables will return an array of strings, which are list of table names
// InsertID returns the identity or insert id of the most recently inserted
// row (does PostgreSql support this?)
abstract public function GetTables();
abstract public function InsertId();
// This will return an array of PostgreSqlDatabaseIndex objects
// or an array of PostgreSqlForeignKey objects given the table name
// This is probably where the bulk of your work will go... figuring out
// a way to get that information via a combination of DESCRIBE, etc.
abstract public function GetIndexesForTable($strTableName);
abstract public function GetForeignKeysForTable($strTableName);
// These handle transactions
abstract public function TransactionBegin();
abstract public function TransactionCommit();
abstract public function TransactionRollBack();
// These handle variable escpaing (e.g. to prevent sql injection atttacks)
abstract public function SqlVariable($mixData, $blnIncludeEquality = false);
abstract public function SqlLimitVariablePrefix($strLimitInfo);
abstract public function SqlLimitVariableSuffix($strLimitInfo);
abstract public function SqlSortByVariable($strSortByInfo);
// Hopefully this is obvious ;^)
abstract public function Close();
Hopefully, this should get you a good start. Also, feel free to take a look at the MySqliDatabase class as a reference.
If you have additional questions (which I'm sure you will ;^) please post 'em and I'll try and respond ASAP.
Thanks for your help!