array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.pg-field-type.php', 1 => 'pg_field_type', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL 関数', ), 'prev' => array ( 0 => 'function.pg-field-type-oid.php', 1 => 'pg_field_type_oid', ), 'next' => array ( 0 => 'function.pg-flush.php', 1 => 'pg_flush', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/pgsql/functions/pg-field-type.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
pg_field_type — フィールド番号に対応する型名を返す
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
クラスのインスタンスを期待するようになりました。
これより前のバージョンでは、リソース を期待していました。
|
例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