Database abstraction layers - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: Database abstraction layers (summary)

Colin McKinnon wrote:

Quoted text here. Click to load it

I've found in practice that surrogates only get you into trouble if you use
them as foreign keys.  Can't offer any high-minded explanation for this, it
just seems to be the case.  The practice is to have a natural primary key
that has some business meaning and also a surrogate key.  The primary key
is used for foreign keys, the surrogate key is used only to simplify tasks
like updates and deletes after the row has been retrieved.  

Every insert command also returns the resulting skey as a NOTICE, so you can
further manipulate the rwo if necessary.

Andromeda adds a surrogate key named "SKEY" for free to every table.  This
makes it possible for the framework, once it has retrieved a set of rows,
to have very simple routines based column "SKEY" that do stuff like  
page-by-page navigation, row selection, updates, and deletes.  

Thanks also for your comments, I hope that you will find some use for

Kenneth Downs
Secure Data Software, Inc.

Re: Database abstraction layers (summary)


on 05/14/2006 06:39 PM Colin McKinnon said the following:
Quoted text here. Click to load it

Before you re-invent the wheel, you may want to take a look at Metabase.

It was the first PHP database abstraction layer to focus on total
database application portability.

This means that not only it provides an API that lets you write database
applications that work without a change to access many RDBMS (MySQL,
PostgreSQL, Oracle, MS SQL server, MS Access, SQLite, Interbase, etc..),
but it also lets you install or upgrade database schemas in a RDBMS
independent way.

Metabase can take database schema definitions in a RDBMS independent XML
format. Then it can install the schema executing the necessary DDL
statements for creating, tables, indexes, keys, sequences, etc..

The greatest part, is that when you want to upgrade the schema of an
already installed application, all you need to do is to change your
schema definition files and ask Metabase to compare and apply the
changes. The schema is upgraded without loosing records added to the
database since it was installed for the first time or upgraded for the
last time.

Metabase is available here:

The tutorial and other documentation is available here:


Manuel Lemos

Metastorage - Data object relational mapping layer generator

PHP Classes - Free ready to use OOP components written in PHP

Re: Database abstraction layers (summary)

Hi Manuel,

It's on my list of things to read next - along with PDOs and


Re: Database abstraction layers

Colin McKinnon wrote:
Quoted text here. Click to load it

Hi Colin,

Imho a database abstraction layer is used to make the same application  
code work on several databases. It sounds like what you are looking for  
is more like an application framework. If you are willing to replace "an  
array of data" by "an object holding data", phpPeanuts can take care of  
either INSERT or UPDATE the data to MySQL, depending on the result of  
$this->isNew(). The code that does it is actually situated on a class  
that will serve as a database abstraction layer once a need for the  
usage of several databases arises. Of course with objects you get much  
more abstraction then just database abstraction, like polymorphism,  
navigation over relationships. PhpPeanuts also adds navigational queries  
(also available in QBE User Interface). Using SQL directly is possible  
in several places, but has the disadvantage that the proper JOIN's will  
not be made automatically, like it is done if you use the Query Model.


Henk Verhoeven,

Re: Database abstraction layers

Hi Henk,

I've had a look at PHPPeanuts and its very impressive. I thought it
would be harder to take it apart to get the bits I want than to tackle
the problem from the ground up. I'll take a look at its inner workings
next time.


Re: Database abstraction layers


I did not read all the messages but i think that DB from would fit your needs?
Take a look at DB_common:autoExecute()


Site Timeline