TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-20-2008, 12:32 AM   #1 (permalink)
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
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:41 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design