View Single Post
Old 01-20-2008, 12:32 AM   #1 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default Your oppinion counts

Howdy everybody. So, I have a DAL system setup, right? I need your thoughts about its implementation, and whether you would want to modify the factory or the interface if you were to develop an Oracle driver for instance - or any other database driver - (it's all about extensibility):

- Interface:

PHP Code:
interface DB_Driver
{
    public static function 
getInstance();
    public function 
connect();
    public function 
select( array $a );
    public function 
insert( array $a );
    public function 
update( array $a );
    public function 
delete( array $a );

- Factory:

PHP Code:
final class DB
{
    public static function 
getInstance$type 'mysql' )
    {
        
// require the database driver
        
self::$instance =& mysql_driver::getInstance();
    }

- and, of course, the mysql driver (the default one):

PHP Code:
class mysql_driver implements DB_Driver
{
    
// singleton, implements the interface methods and its own methods (if you need anything, just write it :)

Only some excerpts are shown here, the real code doesn't matter that much. The idea itself is more important than the actual code.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.

Last edited by xenon : 01-20-2008 at 04:52 AM.
xenon is offline  
Reply With Quote