View Single Post
Old 12-24-07, 03:24 PM   #4
t3hl33td4rg0n
Dethklok Returns!
 
t3hl33td4rg0n's Avatar
 
Join Date: Dec 2004
Location: Kent, OH
Posts: 2,142
Send a message via AIM to t3hl33td4rg0n Send a message via MSN to t3hl33td4rg0n Send a message via Yahoo to t3hl33td4rg0n
Default Re: PHP/Mysql Multiple Questions

Could you do something like this?

Code:
<?php

class db {
	
	public $db1_srvr		= 'mysql1.domain.com';
	public $db1_port		= 3306;
	public $db1_name		= 'user';
	public $db1_pswd		= 'password';
	public $db1_db			= 'foo';

	public $db2_srvr		= 'mysql2.domain.com';
	public $db2_port		= 3306;
	public $db2_name		= 'user';
	public $db2_pswd		= 'password';
	public $db2_db			= 'foo';
	
	public $cdb1;
	public $cdb2;
	
	public $qr1;
	public $qr2;
	
	
	function db_conn ($server) {
		switch ($server) {
			case 1:
				$this->cdb1 = mysqli_connect($this->db1_srvr, $this->db1_name, $this->db1_pswd, $this->db1_db) or die(mysql_error());
			break;
			case 2:
				$this->cdb2 = mysqli_connect($this->db2_srvr, $this->db2_name, $this->db2_pswd, $this->db2_db) or die(mysql_error());
			break;
		}
		return true;
	}
	
	function GenericQuery ($c, $table) {
		$s = 'SELECT * FROM `'.$table.'` SORT BY `uid`';
		if ($c == 1) {
			$q = mysqli_query($cdb1, $s);
			$r = mysqli_fetch_array($q, MYSQL_ASSOC);
			$this->qr1 = $r;
		} elseif ($c == 2) {
			$q = mysqli_query($cdb2, $s);
			$r = mysqli_fetch_array($q, MYSQL_ASSOC);
			$this->qr2 = $r;
		} else {
			die("Invalid Server ID spec");
		}
		
	}
	
	
}
	
	
$dbX = new db();


?>
__________________


Intel QX9650 @ 3.83GHzXFX 780ieVGA GTX 560Ti8GB GSkill DDR800Creative Sound Blaster X-Fi Titanium PCI-ESeagate 1.5TB . 4x Samsung 2TB

Quote:
Originally Posted by MowTin View Post
....it's so clear how government makes things worse not better...
t3hl33td4rg0n is offline   Reply With Quote