View Single Post
Old 06-10-2008, 04:56 AM   #6 (permalink)
delayedinsanity
The Gregarious
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
delayedinsanity is on a distinguished road
Default

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$szPasstrue);

        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($p101DB_HOSTDB_USERDB_PASS, array('dev1''pureftpd')); 
delayedinsanity is offline  
Reply With Quote
The Following User Says Thank You to delayedinsanity For This Useful Post:
SpYkE112 (06-10-2008)