« pg_field_table
pg_field_type_oid »

pg_field_type

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

pg_field_type — フィールド番号に対応する型名を返す

説明

function pg_field_type(PgSql\Result $result, int $field): string

pg_field_type() は、指定した result インスタンスにおいて、指定した field の型名を保持する文字列を 返します。

注意:

フィールドが(基本型ではなく)PostgreSQL ドメインを使用している場合は、 ドメインそのものの名前ではなくドメインの元となっている型の名前を返します。

注意:

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

パラメータ

result

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

field

フィールド番号。0 から始まります。

戻り値

フィールド型の名前を文字列で返します。

変更履歴

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

例

例1 フィールドの情報を取得する

<?php
  $dbconn = pg_connect("dbname=publisher") or die("Could not connect");

  // 'title' は varchar 型と仮定する
  $res = pg_query($dbconn, "select title from authors where author = 'Orwell'");

  echo "Title field type: ", pg_field_type($res, 0);
?>

上の例の出力は以下となります。

Title field type: varchar

参考

関連キーワード:
type   番号   型名   PgSql   インスタンス   ドメイン   query   PostgreSQL   期待   dbconn   connect   title   varchar   Title   table   保持   基本   fieldtype   params   execute   履歴   resource   dbname   publisher   仮定
関連する関数・ページ:
function.pg-field-type-oid   function.pg-field-num   function.pg-field-is-null   function.pg-field-table   function.pg-result-error-field   function.oci-field-type-raw