大网数据广告活动
PHP 语言与运行手册

pg_field_is_null · 测试字段是否为 SQL NULL

· 52CE 我爱测

pg_field_is_null() 测试 PgSql\Result 实例中的字段是否为 SQL NULL。

pg_field_is_null

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

pg_field_is_null — 测试字段是否为 SQL NULL

说明

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

pg_field_is_null() 测试 PgSql\Result 实例中的字段是否为 SQL NULL。

注意:

此函数过去称为 pg_fieldisnull()。

参数

result

PgSql\Result 实例,由 pg_query()、pg_query_params() 或者 pg_execute()(等)返回。

row

要获取的结果中的行号。行从 0 向上编号。如果省略或,则获取当前行。

field

作为 int 的字段编号(从 0 开始)或作为 string 的字段名。

返回值

如果指定行中的字段为 SQL NULL,则返回 1,否则返回 0。如果该行超出范围或发生任何其他错误,则返回 false。

更新日志

版本 说明
8.3.0 row 现在可为 null。
8.1.0 现在 result 参数接受 PgSql\Result 实例,之前接受 resource。

示例

示例 #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";
    }
 }
?>

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。