My post below works but is *not* the correct way. It only works because of default behavior. I'll re-post my understanding of what is "correct" soon.
Ingres 関数
目次
- ingres_autocommit_state — 接続が autocommit を使っているかどうかを調べる
- ingres_autocommit — autocommit をオンまたはオフに切替える
- ingres_charset — 文字セットを返す
- ingres_close — Ingres データベース接続を閉じる
- ingres_commit — トランザクションをコミットする
- ingres_connect — Ingres データベースへの接続をオープンする
- ingres_cursor — 指定した結果リソースのカーソル名を取得する
- ingres_errno — 直近に発生した ingres エラー番号を取得する
- ingres_error — 直近に発生したエラーのエラーメッセージを取得する
- ingres_errsqlstate — 直近に発生した SQLSTATE エラーコードを取得する
- ingres_escape_string — クエリで使うために特殊文字をエスケープする
- ingres_execute — プリペアドクエリを実行する
- ingres_fetch_array — 1 行分の結果を配列に取得する
- ingres_fetch_assoc — 1 行分の結果を連想配列に取得する
- ingres_fetch_object — 1 行分の結果をオブジェクトとして取得する
- ingres_fetch_proc_return — プロシージャコールからの返り値を取得する
- ingres_fetch_row — 1 行分の結果を数値添字配列として取得する
- ingres_field_length — フィールド長を得る
- ingres_field_name — クエリ結果においてフィールド名を得る
- ingres_field_nullable — フィールドに NULL 値を設定可能かどうか調べる
- ingres_field_precision — フィールドの精度を得る
- ingres_field_scale — フィールドのスケールを得る
- ingres_field_type — クエリ結果においてフィールドの型を得る
- ingres_free_result — 結果 ID に関連づけられたリソースを解放する
- ingres_next_error — 次の Ingres エラーを取得する
- ingres_num_fields — 直近のクエリにより返されたフィールドの数を得る
- ingres_num_rows — クエリが変更したり返したりしたレコードの数を取得する
- ingres_pconnect — Ingres データベースへの持続的接続をオープンする
- ingres_prepare — 後で実行するためのクエリを準備する
- ingres_query — Ingres に SQL クエリを送信する
- ingres_result_seek — データを取得する前に行の位置を設定する
- ingres_rollback — トランザクションをロールバックする
- ingres_set_environment — 環境を設定して出力オプションを制御する
- ingres_unbuffered_query — 未バッファ SQL クエリを Ingres に送信する
corysbrain-ondrugs at yahoo dot com ¶
5 years ago
corysbrain-ondrugs at yahoo dot com ¶
6 years ago
On the three versions of Linux/Ingres I've worked on, I've always had to modify the following line in the example above:
while ($iirelation = ingres_fetch_object($link)) {
to:
while ($iirelation = ingres_fetch_object()) {
If not, PHP will return "Undefined property" notices.
However, it's my understanding that the following is the proper way to access the database (it works as expected):
<?php
// Connecting, selecting database
$link = ingres_connect('database', 'user', 'password')
or die('Could not connect: ' . ingres_error($link));
echo 'Connected successfully';
// Select from a table that exists in all Ingres databases
$query = 'SELECT * FROM iirelation';
$rs = ingres_query($link,$query) or die('Query failed: ' .
ingres_error($link));
// Print results in HTML
// relid - table name
// relowner - table owner
echo "<table>\n";
while ($iirelation = ingres_fetch_object($rs)) {
echo "\t<tr>\n";
echo "\t\t<td>" . $iirelation->relid . "</td>\n";
echo "\t\t<td>" . $iirelation->relowner . "</td>\n";
echo "\t</tr>\n";
}
echo "</table>\n";
// Commit transaction
ingres_commit($link);
// Closing connection
ingres_close($link);
?>
