class DB_Oracle {
public $connid; //连接句柄
public $debug = 1; //是否输出调试信息
//初始化数据库信息
function __construct($debug = 1) {
$this->debug = $debug;
}
//数据库连接
function connect($dbhost, $dbuser, $dbpwd, $dbname = '', $charset = 'utf8') { if (!@$this->connid = oci_connect($dbuser, $dbpwd, $dbhost. "/". $dbname, $charset)) {
exit('数据库错误!');
}
return $this->connid;
}
//执行sql语句
function query($sql) {
$stmt = oci_parse($this->connid, $sql);
if(!oci_execute($stmt)) {
$this->halt('执行SQL语句错误', $sql, $stmt);
return false;
}
return $stmt;
}
//执行SELECT语句
function select($sql, $keyField = '') {
$array = array();
$stmt = $this->query($sql);
while ($row = oci_fetch_array($stmt, OCI_BOTH)) {
if(!$keyField) {
$array[] = $row;
} else {
$array[] = $row[$keyField];
}
}