Location: PHPKode > scripts > Scrubs > scrubs/DataStore.php
<?php

/**
 * 
 *
 * @version $Id$
 * @copyright 2003 
 **/

define('SCRUBS', dirname(dirname(__FILE__)));

include_once(SCRUBS."/lib/adodb/adodb.inc.php");
include_once(SCRUBS."/lib/Configer.php"); 

class DataStore {

	var $dbType     = "";
	var $dbHost     = "";
	var $dbStore    = "";
	var $dbUserName = "";
	var $dbPassword = "";
	var $debug      = true;
	
	function DataStore() {
		$this->configure();
	}
	
	function configure() {
		$c = new Configer(null, true);
		$dbr = array();
		
		$dbr = $c->getSection("database");
		$this->dbType     = $dbr['type'];
		$this->dbHost     = $dbr['host'];
		$this->dbStore    = $dbr['database'];
		$this->dbUserName = $dbr['username'];
		$this->dbPassword = $dbr['password'];
	}
	
	function connect() {
		$dbc = &ADONewConnection($this->dbType);
		$dbc->debug = $this->debug;
		$dbc->SetFetchMode(ADODB_FETCH_ASSOC);
		$dbc->Connect($this->dbHost, $this->dbUserName, $this->dbPassword, $this->dbStore);
		if(!$dbc) {
			print $dbc->ErrorMsg();
			return false;
		} else {
			return $dbc;
		}		
	}

}
?>
Return current item: Scrubs