View Single Post
Old 06-01-2008, 01:15 AM   #4 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 1,578
Thanks: 72
Wildhoney is on a distinguished road
Default

Pleasure !

In theory though you could go down the abstract path, with something like so:

php Code:
abstract class Database_Abstract
{
    abstract function insertRow($aData);
    abstract function updateRow($aData, $iRowId);
    abstract function deleteRow($iRowId);
   
    public function __construct()
    {
        printf("Connection established\n");
    }
}

class Database_MySQL extends Database_Abstract
{
    public function insertRow($aData) { return 'Insert MySQL'; }
    public function updateRow($aData, $iRowId) { return 'Update MySQL'; }
    public function deleteRow($iRowId) { return 'Delete MySQL'; }
}

$pDb = new Database_MySQL();
echo $pDb->insertRow(array(1, 2));

However, the reason I would take the former path, as aforesaid in my earlier post, is due to the logging and other centralised functionality that would be beneficial to the overall harmony of a database class. Whenever you make a call in the former, you can perform any generic tasks, such as logging, whereas if you take the latter route, with abstracts, you'll have to set-up logging in each individual child class, or at least call a function from the abstract.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
coiyeun2b (06-29-2008)