<?php
Class DBI extends CONFIG
{
/*******************************************************************************
Description : PHP Database Interface
Author : Thomas Werner
Author Email : thomas.werner@ideaweb.de
Created : 20000801
Last Modified : 20001201
Info : n/a
*******************************************************************************/
var $DBD;
var $CONN;
var $prepare = "";
var $row = array();
function error($str)
{
echo "$str<BR>\n";
exit;
} // End Error
function DBI()
{
$dbtype = $this->dbtype;
if(!$GLOBALS['lib_dbd_'.$dbtype."_read"]) {
include('lib_dbd_'.$dbtype.'.class');
}
$DBDClass = 'DBD_'.$dbtype;
$this->DBD = new $DBDClass;
//$this->pconnect();
}
function connect()
{
$dbtype = $this->dbtype;
$dbhost = $this->dbhost;
$port = $this->port;
$dbname = $this->dbname;
$dbuser = $this->dbuser;
$dbpwd = $this->dbpwd;
$this->CONN = $this->DBD->connect($dbname,$dbhost.":".$port,$dbuser,$dbpwd);
return true;
} // End Connect
function pconnect()
{
$dbtype = $this->dbtype;
$dbhost = $this->dbhost;
$port = $this->port;
$dbname = $this->dbname;
$dbuser = $this->dbuser;
$dbpwd = $this->dbpwd;
$this->CONN = $this->DBD->pconnect($dbname,$dbhost.":".$port,$dbuser,$dbpwd);
return true;
} // End Connect
function disconnect()
{
if($this->DBD){
$this->DBD->disconnect();
}
} // End Disconnect
function prepare($query)
{
if(!$this->CONN){return;}
$sth = $this->DBD->prepare($query);
return($sth);
} // End Prepare
function value($table, $id, $name)
{
if ( $this->CONN) {
$dbexec = $this->DBD->prepare("SELECT * FROM $table WHERE ID = $id");
if ( $dbexec->execute() && $dbexec->rows() > 0 ) {
$row = $dbexec->fetchrow_hashref();
return $row->{$name};
}
}
return false;
} // End value
} // End Class
$GLOBALS[lib_dbi_read] = 1;
?> |