[pLog-svn] r2190 - plog/trunk/class/database
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Fri Jun 10 12:13:56 GMT 2005
Author: oscar
Date: 2005-06-10 12:13:56 +0000 (Fri, 10 Jun 2005)
New Revision: 2190
Modified:
plog/trunk/class/database/db.class.php
Log:
I think I forgot to commit this...
Modified: plog/trunk/class/database/db.class.php
===================================================================
--- plog/trunk/class/database/db.class.php 2005-06-10 09:46:51 UTC (rev 2189)
+++ plog/trunk/class/database/db.class.php 2005-06-10 12:13:56 UTC (rev 2190)
@@ -8,8 +8,8 @@
include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
include_once( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" );
- include_once( PLOG_CLASS_PATH."class/database/adodb/adodb.inc.php" );
- //include_once( PLOG_CLASS_PATH."class/database/pdb/pdb.class.php" );
+ //include_once( PLOG_CLASS_PATH."class/database/adodb/adodb.inc.php" );
+ include_once( PLOG_CLASS_PATH."class/database/pdb/pdb.class.php" );
/**
* \ingroup Database
@@ -33,8 +33,8 @@
// we need to connect to the db
$fileConfig = new ConfigFileStorage();
- $db = NewADOConnection('mysql');
- //$db = PDb::getDriver('mysql');
+ //$db = NewADOConnection('mysql');
+ $db = PDb::getDriver('mysql');
$username = $fileConfig->getValue( "db_username" );
$password = $fileConfig->getValue( "db_password" );
@@ -48,13 +48,37 @@
// just in case, forcing to use indexing by field name instead of
// by field number
- $db->SetFetchMode( ADODB_FETCH_ASSOC );
+ //$db->SetFetchMode( ADODB_FETCH_ASSOC );
// comment out the line above if you're planning to test pdb
}
return $db;
}
+
+ function &getNewDb( $host, $username, $password, $dbname )
+ {
+ static $dbs;
+
+ if( !is_array( $dbs ))
+ $dbs = Array();
+
+ $key = $user.$pass.$host.$dbname;
+
+ if( !isset( $dbs[$key] )) {
+ $dbs[$key] = PDb::getDriver('mysql');
+ if( !$dbs[$key]->PConnect( $host, $username, $password, $dbname )) {
+ throw( new Exception( "getNewDb: Fatal error: could not connect to the database!" ));
+ die();
+ }
+ // just in case, forcing to use indexing by field name instead of
+ // by field number
+ //$db->SetFetchMode( ADODB_FETCH_ASSOC );
+ }
+
+ return( $dbs[$key] );
+ }
+
function &getDbCache()
{
static $dbcache;
More information about the pLog-svn
mailing list