test.php
  1. <?php  
  2. //----------------------------------------------------------------------------- 기본 설정 START  
  3. $con = ocilogon($common_oracle_id,$common_oracle_passwd,$common_oracle_sid) or error("DB_CONNECT_ERROR");  
  4. //----------------------------------------------------------------------------- 기본 설정 END 
test.php
  1. // select  
  2. //---------------------------------------------------------------------------- S  
  3. $sql = "select * from table where a = b";  
  4. //echo "<pre>$sql</pre>";  
  5. $stmt = ociparse($con,$sql);  
  6. $result = ociexecute($stmt,OCI_DEFAULT);  
  7. for( $i=0 ; ocifetchinto($stmt,&$row) ; $i++ )  
  8. {  
  9.     $aaaaaaaaa      = $row[0];  
  10. }  
  11. ocifreestatement($stmt);  
  12. //---------------------------------------------------------------------------- E 
test.php
  1. // insert, update  
  2. //---------------------------------------------------------------------------- S  
  3. $sql = "insert into table ...";  
  4. //echo "<pre>$sql</pre>"; exit;  
  5. $stmt = ociparse($con, $sql);  
  6. $result = ociexecute($stmt,OCI_DEFAULT);  
test.php
  1. if(!$result)  
  2. {  
  3.     $ocierror = ocierror($stmt);  
  4.     $error_code = $ocierror["code"];  
  5.     $error_message = trim($ocierror["message"]);  
  6.       
  7.     // 에러 발생 시, rollback  
  8.     ocirollback($con);  
test.php
  1.     $tg_error = "1"; //★error구분 1,2,3,4 SQL,File,보안위배,입력위배  
  2.     $tx_message = " ERROR"; // error message  
  3.       
  4.     seterror($con, $REQUEST_URI, $tg_error, $tx_message, $sql);  
test.php
  1.     ocifreestatement($stmt);  
test.php
  1.     ocilogoff($con);  
  2.     exit;  
  3. }  
  4. ocifreestatement($stmt);  
test.php
  1. // 성공시 commit 해줘야 실제 데이터 처리가 이뤄짐.  
  2. ocicommit($con);  
test.php
  1. ocilogoff($con);  
  2. exit;  
  3. ?>