LVIII. 오라클 8 함수
이 함수들은 Oracle8과 Oracle7 데이터베이스에 접근할 수 있도록 해준다.
이것은 Oracle8 Call-Interface (OCI8)를 사용한다.
이 드라이버를 사용하려면 Oracle8 client libraries가 필요하다.
이 드라이버는 보통의 PHP Ora_ 드라이버보다 더욱 유연하다.
이것은 PHP의 전역, 지역 변수들의 Oracle placeholder로의 binding을 지원하고,
full LOB와 FILE, ROWID를 지원하며, user-supplied define variable을
사용할 수 있도록 해 준다.
이 드라이버를 사용하기 전에 오라클 유저와 웹서버 유저에게
유효한 오라클 환경변수를 적용했는지 확인해야한다.
적용시킬 환경변수:
ORACLE_HOME
ORACLE_SID
LD_PRELOAD
LD_LIBRARY_PATH
NLS_LANG
ORA_NLS33
웹서버 유저에게 환경변수를 적용한후에,
웹서버 유저(nobody, www)를 오라클 그룹에 추가했는지 확인해야 한다.
예 1. OCI Hints
<?php
// by sergo@bacup.ru
// Use option: OCI_DEFAULT for execute command to delay execution
OCIExecute($stmt, OCI_DEFAULT);
// for retrieve data use (after fetch):
$result = OCIResult($stmt, $n);
if (is_object ($result)) $result = $result->load();
// For INSERT or UPDATE statement use:
$sql = "insert into table (field1, field2) values (field1 = 'value',
field2 = empty_clob()) returning field2 into :field2";
OCIParse($conn, $sql);
$clob = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob->save ("some text");
?>
|
|
command-line에서 내장 프로시저(stored procedures)를 쓰는것처럼
사용이 간편하다.
예 2. 내장 프로시저(Stored Procedures) 사용하기
<?php
// by webmaster@remoterealty.com
$sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname',
'$lastname', '$company', '$address1', '$address2', '$city', '$state',
'$postalcode', '$country', :error_code );end;" );
// This calls stored procedure sp_newaddress, with :address_id being an
// in/out variable and :error_code being an out variable.
// Then you do the binding:
OCIBindByName ( $sth, ":address_id", $addr_id, 10 );
OCIBindByName ( $sth, ":error_code", $errorcode, 10 );
OCIExecute ( $sth );
?>
|
|