PHP 8.3.4 Released!

pg_field_is_null

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

pg_field_is_nullフィールドが SQL の NULL かどうか調べる

説明

pg_field_is_null(PgSql\Result $result, string|false|null $row, mixed $field): int
pg_field_is_null(PgSql\Result $result, mixed $field): int

pg_field_is_null() は、 PgSql\Result クラスのインスタンスの フィールドが SQL の NULL であるかどうかを調べます。

注意:

この関数は、以前は pg_fieldisnull() と呼ばれていました。

パラメータ

result

pg_query()pg_query_params() や (様々な関数がありますが、特に) pg_execute() が返した PgSql\Result クラスのインスタンス。

row

取得する結果の行番号。行番号は 0 から始まります。指定しなかった場合は カレントの行を取得します。

field

(0 から始まる)フィールド番号を表す数値、 あるいはフィールド名を表す文字列。

戻り値

指定した行のフィールドが SQL の NULL だった場合に 1、そうでない場合に 0 を返します。 もし範囲外の行を指定したりその他のエラーが発生したりした場合には false を返します。

変更履歴

バージョン 説明
8.3.0 row は、nullable になりました。
8.1.0 result は、PgSql\Result クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、リソース を期待していました。

例1 pg_field_is_null() の例

<?php
$dbconn
= pg_connect("dbname=publisher") or die ("Could not connect");
$res = pg_query($dbconn, "select * from authors where author = 'Orwell'");
if (
$res) {
if (
pg_field_is_null($res, 0, "year") == 1) {
echo
"The value of the field year is null.\n";
}
if (
pg_field_is_null($res, 0, "year") == 0) {
echo
"The value of the field year is not null.\n";
}
}
?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top