If you've followed the instructions and you can't even connect to the DB server, welcome to the Oracle hell. Most of the information you'll find is deprecated, incomplete, not for your platform, unnecessary or just plain wrong.
Typically, you won't need at all those complicate setups you'll read about and they'll probably make things harder. I suggest you get Systernal's "Filemon" utility (for Windows, in Unix you may do with strace) and find out what exact config files and DLLs are being tried by php.exe (or httpd.exe if PHP runs as Apache module or...). Pretty often, the issue is that (e.g.) TNSNAMES.ORA does not have the correct line ending or Apache is looking for a DLL that does not even exist in your hard disc; learning that prevents you to waste time adding more and more useless environmental variables.
Goog luck.
OCI8 関数
目次
- oci_bind_array_by_name — PHP の配列を Oracle PL/SQL の配列に名前でバインドする
- oci_bind_by_name — Oracle プレースホルダーに PHP 変数をバインドする
- oci_cancel — カーソルからの読み込みをキャンセルする
- oci_close — Oracleとの接続を閉じる
- OCI-Collection->append — コレクションに要素を追加する
- OCI-Collection->assign — コレクションに他の存在するコレクションから値を割り当てる
- OCI-Collection->assignElem — コレクションの要素に値を割り当てる
- OCI-Collection->free — コレクションオブジェクトに関連付けられたリソースを解放する
- OCI-Collection->getElem — 要素の値を返す
- OCI-Collection->max — コレクション内の要素の最大数を取得する
- OCI-Collection->size — コレクションのサイズを返す
- OCI-Collection->trim — コレクションの最後から要素を切り取る
- oci_commit — 未解決の文をコミットする
- oci_connect — Oracle サーバへの接続を確立する
- oci_define_by_name — SELECT 実行中、定義用の PHP 変数を使用する
- oci_error — 最後に見つかったエラーを返す
- oci_execute — 文を実行する
- oci_fetch_all — 結果データの全ての行を配列に取得する
- oci_fetch_array — 結果データからの次の行を連想配列または配列、またはその両方で返す
- oci_fetch_assoc — 結果データの次の行を連想配列で返す
- oci_fetch_object — 結果の次の行をオブジェクトとして返す
- oci_fetch_row — 結果データの次の行を配列で返す
- oci_fetch — 結果バッファの次の行を取得する
- oci_field_is_null — フィールドが NULL であるかどうかを確認する
- oci_field_name — 文からのフィールド名を返す
- oci_field_precision — フィールドの精度を問い合わせる
- oci_field_scale — フィールドの桁数を問い合わせる
- oci_field_size — フィールドサイズを返す
- oci_field_type_raw — Oracle におけるフィールドの型を問い合わせる
- oci_field_type — フィールドのデータ型を返す
- oci_free_statement — 文やカーソルに関連付けられた全てのリソースを解放する
- oci_internal_debug — 内部デバッグ用出力有効または無効にする
- OCI-Lob->append — ラージオブジェクトのデータを他のラージオブジェクトに追加する
- OCI-Lob->close — LOB ディスクリプタを閉じる
- oci_lob_copy — ラージオブジェクトをコピーする
- OCI-Lob->eof — ラージオブジェクトのディスクリプタが EOF かどうかを調べる
- OCI-Lob->erase — 内部 LOB データの特定の位置を消去する
- OCI-Lob->export — LOB の内容をファイルに出力する
- OCI-Lob->flush — LOB のバッファをサーバにフラッシュする、あるいは書き込む
- OCI-Lob->free — LOB ディスクリプタに関連付けられたりソースを解放する
- OCI-Lob->getBuffering — ラージオブジェクトに対する現在のバッファリングの状態を返す
- OCI-Lob->import — ファイルデータを LOB にインポートする
- oci_lob_is_equal — 2 つの LOB/FILE ロケータの等価性を比較する
- OCI-Lob->load — ラージオブジェクトの内容を返す
- OCI-Lob->read — ラージオブジェクトの一部を読み込む
- OCI-Lob->rewind — 内部ポインタをラージオブジェクトの先頭に移動する
- OCI-Lob->save — データをラージオブジェクトに保存する
- OCI-Lob->saveFile — oci_lob_import のエイリアス
- OCI-Lob->seek — ラージオブジェクトの内部ポインタをセットする
- OCI-Lob->setBuffering — 現在のラージオブジェクト用のバッファリング状態を変更する
- OCI-Lob->size — ラージオブジェクトのサイズを返す
- OCI-Lob->tell — ラージオブジェクトの内部ポインタの現在位置を返す
- OCI-Lob->truncate — ラージオブジェクトを切りつめる
- OCI-Lob->write — データをラージオブジェクトに書き込む
- OCI-Lob->writeTemporary — 一時的なラージオブジェクトを書き込む
- OCI-Lob->writeToFile — oci_lob_export のエイリアス
- oci_new_collection — 新しいコレクションオブジェクトを割り当てる
- oci_new_connect — Oracle サーバへの新規接続を確立する
- oci_new_cursor — 新規カーソル (ステートメントハンドル) を割り当て、それを返す
- oci_new_descriptor — 空の新規 LOB あるいは FILE ディスクリプタを初期化する
- oci_num_fields — ある文における結果のカラム数を返す
- oci_num_rows — 文の実行で作用された行数を取得する
- oci_parse — 実行のために Oracle の文をパースする
- oci_password_change — Oracle ユーザのパスワードを変更する
- oci_pconnect — 持続的接続を使用してOracle データベースに接続する
- oci_result — フェッチした行からフィールドの値を取得する
- oci_rollback — 未解決のトランザクションをロールバックする
- oci_server_version — サーバのバージョンを返す
- oci_set_action — Sets the action name
- oci_set_client_identifier — Sets the client identifier
- oci_set_client_info — Sets the client information
- oci_set_edition — Sets the database edition
- oci_set_module_name — Sets the module name
- oci_set_prefetch — プリフェッチする行数を設定する
- oci_statement_type — OCI ステートメントの種類を返す
- ocibindbyname — oci_bind_by_name のエイリアス
- ocicancel — oci_cancel のエイリアス
- ocicloselob — のエイリアス
- ocicollappend — のエイリアス
- ocicollassign — のエイリアス
- ocicollassignelem — のエイリアス
- ocicollgetelem — のエイリアス
- ocicollmax — のエイリアス
- ocicollsize — のエイリアス
- ocicolltrim — のエイリアス
- ocicolumnisnull — oci_field_is_null のエイリアス
- ocicolumnname — oci_field_name のエイリアス
- ocicolumnprecision — oci_field_precision のエイリアス
- ocicolumnscale — oci_field_scale のエイリアス
- ocicolumnsize — oci_field_size のエイリアス
- ocicolumntype — oci_field_type のエイリアス
- ocicolumntyperaw — oci_field_type_raw のエイリアス
- ocicommit — oci_commit のエイリアス
- ocidefinebyname — oci_define_by_name のエイリアス
- ocierror — oci_error のエイリアス
- ociexecute — oci_execute のエイリアス
- ocifetch — oci_fetch のエイリアス
- ocifetchinto — 結果配列の次の行を取得する (非推奨)
- ocifetchstatement — oci_fetch_all のエイリアス
- ocifreecollection — のエイリアス
- ocifreecursor — oci_free_statement のエイリアス
- ocifreedesc — のエイリアス
- ocifreestatement — oci_free_statement のエイリアス
- ociinternaldebug — oci_internal_debug のエイリアス
- ociloadlob — のエイリアス
- ocilogoff — oci_close のエイリアス
- ocilogon — oci_connect のエイリアス
- ocinewcollection — oci_new_collection のエイリアス
- ocinewcursor — oci_new_cursor のエイリアス
- ocinewdescriptor — oci_new_descriptor のエイリアス
- ocinlogon — oci_new_connect のエイリアス
- ocinumcols — oci_num_fields のエイリアス
- ociparse — oci_parse のエイリアス
- ociplogon — oci_pconnect のエイリアス
- ociresult — oci_result のエイリアス
- ocirollback — oci_rollback のエイリアス
- ocirowcount — oci_num_rows のエイリアス
- ocisavelob — のエイリアス
- ocisavelobfile — のエイリアス
- ociserverversion — oci_server_version のエイリアス
- ocisetprefetch — oci_set_prefetch のエイリアス
- ocistatementtype — oci_statement_type のエイリアス
- ociwritelobtofile — のエイリアス
- ociwritetemporarylob — のエイリアス
OCI8 関数
alvaro at demogracia dot com
10-Jun-2008 08:24
10-Jun-2008 08:24
christopher dot jones at oracle dot com
18-Jun-2007 01:25
18-Jun-2007 01:25
There are several good books on PHP and Oracle available - search your favorite bookstore. There is also a free book from Oracle "The Underground PHP and Oracle Manual" that covers the OCI8 extension: http://otn.oracle.com/tech/php/pdf/underground-php-oracle-manual.pdf
(free registration for OTN required, IIRC). Disclaimer: I'm one of its authors.
James VL
01-Mar-2007 03:49
01-Mar-2007 03:49
re: Andrei Kubar
I was using Oracle Instant Client on Windows XP, and was getting the
PHP Startup: Unable to load dynamic library 'C:\php\ext\php_oci8.dll' - The specified module could not be found.
error at startup, even though I had done all (most?) of the PHP and Oracle setup routines.
For me it wasn't the lack of mfc*.dll files, but a simple PATH issue: in addition to defining the environment variable TNS_ADMIN, I had to include my instant client directory in my PATH.
darkstar_ae at hotmail dot com
26-Apr-2005 02:39
26-Apr-2005 02:39
When fetching associative arrays, use uppercase string indices. It appears the PHP OCI Library is less lenient with the field names returned by Oracle.
e.g.
echo $row['field1']; // This won't return anything.
as opposed to:
echo $row['FIELD1'];
edahnke at consultant dot com
09-Jan-2002 05:01
09-Jan-2002 05:01
Here's a little snipet that shows how to insert multiple clob fields. Worked for me.
$dbh = OCILogon($dst_user_name, $dst_password, $dst_db_name);
for($i = 0; $i < $src_rec_cnt; $i++) {
$query = "insert into bid (id,time,resume,experience,comments) values ('$id[$i]','$time[$i]',empty_clob(),empty_clob(),empty_clob()) returning resume,experience,comments into :resume,:experience,:comments";
$stmt = OCIParse($dbh, $query);
$clob1 = OCINewDescriptor($dbh, OCI_D_LOB);
$clob2 = OCINewDescriptor($dbh, OCI_D_LOB);
$clob3 = OCINewDescriptor($dbh, OCI_D_LOB);
OCIBindByName ($stmt, ":resume", &$clob1, -1, OCI_B_CLOB);
OCIBindByName ($stmt, ":experience", &$clob2, -1, OCI_B_CLOB);
OCIBindByName ($stmt, ":comments", &$clob3, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
@$clob1->save ($resume[$i]);
@$clob2->save ($experience[$i]);
@$clob3->save ($comments[$i]);
OCICommit($dbh);
doug at redhive dot com
20-Jul-2001 06:38
20-Jul-2001 06:38
if you feel like you have too many oracle statements clouding up your php, i came up with a function to open a connection (if necessary), parse your sql statement, and return the executed query. after you call the function, you can do whatever needs to be done. makes like so much simpler: (do whatever you want with the errors)
function execute_query($query, &$connected) {
global $ORACLE_USER, $ORACLE_PASS, $ORACLE_SID;
if(!$connected) {
$connected = @OCIPLogon($ORACLE_USER, $ORACLE_PASS, $ORACLE_SID);
if($error = OCIError()) {
die("<font color=red>ERROR!! Couldn't connect to server!</font>");
}
}
$stmt = @OCIParse($connected, $query);
if($error = OCIError($cn)) {
die("<font color=red>ERROR!! Statement syntax error!</font>");
}
@OCIExecute($stmt);
if($error = OCIError($stmt)) {
die("<font color=red>ERROR!! Could not execute statement!</font>");
}
return $stmt;
}
jasendorf at lcounty dot com
24-May-2001 07:48
24-May-2001 07:48
VERY IMPORTANT! OCIPLogon only keeps a persistent connection if you are running PHP as a module. This is particularly important to Windows users who are used to running PHP as a CGI.
junk at netburp dot com
19-Oct-2000 06:39
19-Oct-2000 06:39
Here's a clue about rowid.
Don't forget about the oracle functions:
"rowidtochar" and "chartorowid"
"select rowidtochar(rowid) as FOO from table ...."
When you want to pass the rowid in a form or link, that's
the only way to go.
