View Single Post
Old 11-08-2007, 06:49 PM   #13 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 978
Thanks: 103
Tanax is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
hey,

sorry i havent posted in a while, ive been busy.

anyway
bluesaga is correct about PHP5 and referencing, i do know that the new keyword returns a reference by default but i am unsure about returning from functions and i must admit i havent tested to see (if sum1 else knows please let me know :) ).

@Tanax i am unsure about your question, can u elaborate more?

just add to the switch for oracle (if thats what your question was :confused:)
Nono, that wasn't my question ;)

My question was that if I have several database classes, for instance mysql, mssql, and oracle.

Then I will have the switch, and creates objects of the class depending on what type.
But how will it create an object of a class, in ANOTHER file.

I have this DBfactory.php where the static factory method is.
Then I have a new file for each of the database types.

DBmysql.php
DBmssql.php
DBoracle.php

Which means, that I have to include them in order to create the object like so:
PHP Code:
new DBmysql(); 
And where do I include them?

Like this?
PHP Code:
switch($type) {
                    
                    case 
'mysql':
                        include_once(
'DB'.$type.'.php');
                        
self::$DB = new DBmysql;
                        break;
                        
                    case 
'mssql':
                        include_once(
'DB'.$type.'.php');
                        
self::$DB = new DBmssql;
                        break;
                        
                    default:
                        include_once(
'DB'.$type.'.php');
                        
self::$DB = new DBmysql;
                        break;
                        
                } 
Tanax is offline  
Reply With Quote