11-23-2007, 04:17 PM
|
#24 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 127
Thanks: 14
|
Nice article, I learned a bunch.
For those who want to query multiple databases within the same page. Comment out and where it checks if $pDB is an object or not. Or else, since $pDB is static, you will only be able to instantiate one database. :)
Also, I'm not quite done modifying my database factory. But I do think it'd be neat to implement something like this:
PHP Code:
public static $_dbTypes = array( 'mysql' => 'MySQL', 'odbc' => 'ODBC' );
...
public static function factory($type) { //if(!is_object(self::$_db)) { if(array_key_exists($type, self::$_dbTypes)) { echo $type . ' is a supported database!<br />'; self::$_db = new self::$_dbTypes[$type]; } else { throw new Exception($type . ' is not a supported database!'); } //} return self::$_db; }
It's not perfect and yes, $_db is static, but it's work in progress. :)
|
|
|
|