06-10-2008, 03:56 AM
|
#6 (permalink)
|
|
The Gregarious
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
|
I just noticed you removed the switch in your second code block. So I did too, and tidied it up a bit more. *shrug* Probably pointless if my last one didn't work, but I'm listening to CSPAN right now, so I kind of just did it in a daze.
PHP Code:
public function __construct (p101 $p101, $szHost, $szUser, $szPass, $aDBs) {
foreach($aDBs as $value) { $this->link[$value] = mysql_connect($szHost, $szUser, $szPass, true);
if (!$this->link[$value]) { $p101->error[] = 'Unable to connect to database: '.mysql_error(); return false;
} else { if (!mysql_select_db($value, $this->link[$value])) { $p101->error[] = 'Unable to select database: '.$value.'. '.mysql_error(); return false; } } // if
} // foreach
}
...then if you want you could deliver your host/user/pass dynamically or store them in a configuration constant somewhere and use it something like so:
PHP Code:
$aDBs = array( 'dev1', 'pureftpd' );
$pDatabase = new database($p101, 'localhost', 'SpYkE112', '', $aDBs);
// or with constants defined elsewhere
$pDatabase = new database($p101, DB_HOST, DB_USER, DB_PASS, array('dev1', 'pureftpd'));
|
|
|
|