<?php

class db_interface {

	var $master;
	var $slave;
	var $resource;

	function db_connect(){
		switch (DB_TYPE) {
			case "mysql":
				$master = mysql_connect (DB_MASTER_HOST.":".DB_MASTER_PORT,DB_USER,DB_PASS);
				$slave = mysql_connect (DB_SLAVE_HOST.":".DB_SLAVE_PORT,DB_USER,DB_PASS);
			break;
			case "postresql":
				//$master = pg_connect();
				//$slave = pg_connect();
			break
		}
		
	}

	function db_query($query){
		switch (DB_TYPE) {
			case "mysql":
				$this->resource = mysql_query($query,$master);
			break;
			case "postresql":
			break
		}
	}

	function db_update($update){
		switch (DB_TYPE) {
			case "mysql":
				$this->resource = mysql_query($update,$slave);
			break;
			case "postresql":
			break
		}
	}

	function db_insert($insert){
		switch (DB_TYPE) {
			case "mysql":
				$this->resource = mysql_query($insert,$slave);
			break;
			case "postresql":
			break
		}
	}

	function db_close(){
		switch (DB_TYPE) {
			case "mysql":
				mysql_close($master);
				mysql_close($slave);
			break;
			case "postresql":
			break
		}
	}

	function db_fetch_object($resource){
		switch (DB_TYPE) {
			case "mysql":
				if($object = mysql_fetch_object($resource)){
					return $object;
				}else{
					return false;
				}
			break;
			case "postresql":
			break
		}
	}

}
?>