138 lines
3.3 KiB
PHP
138 lines
3.3 KiB
PHP
<?php
|
|
class Oracle_OCI_log {
|
|
var $conn = FALSE;
|
|
var $stmt = 0;
|
|
var $abstractData= FALSE;
|
|
var $error= FALSE;
|
|
|
|
function connect($id="oracle_id",$passwd="oracle_passwd",$oracle_sid="SID") { // 오라클 접속.
|
|
$this->conn = OCILogon($id,$passwd,$oracle_sid);
|
|
}
|
|
|
|
function serverVersion() {
|
|
return OCIServerVersion($this->conn);
|
|
}
|
|
|
|
function parse($qry) {
|
|
$this->stmt=OCIParse($this->conn,$qry);
|
|
}
|
|
|
|
function parseExec($qry) {
|
|
$this->stmt=OCIParse($this->conn,$qry);
|
|
$this->exec();
|
|
}
|
|
|
|
function exec($mode=OCI_DEFAULT) {
|
|
// OCI_DEFAULT : 매번 실행시마다 자동 commit가 되지 않도록 함.
|
|
@OCIExecute($this->stmt,$mode);
|
|
$this->error = ocierror($this->stmt);
|
|
if($this->error) $this->disconnect();
|
|
}
|
|
|
|
/*
|
|
OCI_D_FILE
|
|
OCI_D_LOB
|
|
OCI_D_ROWID
|
|
*/
|
|
|
|
function newDescriptor($type) {
|
|
$this->abstractData = OCINewDescriptor($this->conn,$type);
|
|
}
|
|
|
|
function freeDescriptor() {
|
|
OCIFreeDescriptor($this->abstractData);
|
|
}
|
|
|
|
function defineByName($upper,&$var) {
|
|
OCIDefineByName($this->stmt,$upper,&$var);
|
|
}
|
|
|
|
function bindByName($place_holder,&$var,$length) {
|
|
OCIBindByName($this->stmt,$place_holder,$var,$length);
|
|
}
|
|
|
|
/*
|
|
OCI_B_FILE(Binary File)
|
|
OCI_B_CFILE(Character-File)
|
|
OCI_B_CLOB(Character_LOB)
|
|
OCI_B_BLOB(Binary-LOB)
|
|
OCI_B_B_ROWID(ROWID)
|
|
*/
|
|
|
|
function bindByNameAbstract($place_holder,$type) {
|
|
OCIBindByName($this->stmt,$place_holder,&$this->abstractData,-1,$type);
|
|
return $this->abstractData;
|
|
// return &$this->abstractData; PARSE ERROR!
|
|
}
|
|
|
|
|
|
function fetch() {
|
|
return OCIFetch($this->stmt);
|
|
}
|
|
|
|
function result($i) { // 인덱스는 0이 아닌 1부터 시작
|
|
return OCIresult($this->stmt,$i);
|
|
}
|
|
|
|
function fetchInto(&$col,$mode=OCI_ASSOC) { // 클래스는 디폴트가 OCI_ASSOC
|
|
//function fetchInto(&$col,$mode=OCI_NUM) {
|
|
return OCIFetchInto($this->stmt,&$col,$mode);
|
|
}
|
|
|
|
function fetchStatement(&$arr) {
|
|
return OCIFetchStatement($this->stmt,&$arr);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////
|
|
function numCols() {
|
|
return OCINumCols($this->stmt);
|
|
}
|
|
|
|
// $index 는 1 부터 시작
|
|
function columnName($index) {
|
|
return OCIColumnName($this->stmt,$index);
|
|
}
|
|
|
|
function columnisNULL($index) {
|
|
return OCIColumnIsNULL($this->stmt,$index);
|
|
}
|
|
|
|
function columnType($index) {
|
|
return OCIColumnType($this->stmt,$index);
|
|
}
|
|
|
|
function columnSize($index) {
|
|
return OCIColumnSize($this->stmt,$index);
|
|
}
|
|
|
|
function StatementType() {
|
|
return OCIStatementType($this->stmt);
|
|
}
|
|
|
|
function rowCount() {
|
|
return OCIRowCount($this->stmt);
|
|
}
|
|
///////////////////////////////////////////////
|
|
|
|
function parseFree() {
|
|
OCIFreeStatement($this->stmt);
|
|
}
|
|
|
|
function disconnect() {
|
|
if($this->error) {
|
|
OCIRollback($this->conn);
|
|
die("<font color=red>ROLLBACK OCCURRED!! ".$this->error["message"]."</font>");
|
|
}
|
|
else {
|
|
OCICommit($this->conn);
|
|
}
|
|
OCILogoff($this->conn);
|
|
}
|
|
|
|
} // end class
|
|
|
|
//////// Object 생성 ////////////////////////////////
|
|
//$oci = new Oracle_OCI;
|
|
//////////////////////////////////////////////////////////////
|
|
?>
|