user = $user; $this->pass = $pass; $this->host = $host; $this->dbName = $dbName; } public function connect() { $dsn['username'] = $this->user; $dsn['password'] = $this->pass; $dsn['hostspec'] = $this->host; $dsn['phptype'] = $this->dbtype; $this->db =& MDB2::factory($dsn); # if the db wasn't successful say why if (PEAR::isError($this->db)) { die(__LINE__.$this->db->getMessage()); } $this->db->setOption('result_buffering', true); $this->db->setFetchMode(MDB2_FETCHMODE_ASSOC); $this->db->loadModule('Extended'); # switch to the appropriate db $this->db->setDatabase($this->dbName); # identify that we have a connection $this->connected = true; return $this->db; } } ############################################################################### # This is how we could do a simple connection # in the older less portable fashion using mysql_connect # mysql_connect('localhost', '4350', 'wsuslcc'); # mysql_select_db('project5'); # $result = mysql_query('show tables'); # for ($i=0; $i