(PHP 4 >= 4.3.0, PHP 5, PHP 7)
pg_meta_data — テーブルからメタデータを取得する
$connection
, string $table_name
[, bool $extended = FALSE
] ) : arraypg_meta_data() は、table_name のテーブル定義を配列として返します。
connectionPostgreSQL データベースの接続リソース。
table_nameテーブルの名前。
extended
拡張メタデータを返すかどうかを表すフラグ。デフォルトは FALSE。
テーブル定義の配列を返します。エラー時には FALSE を返します。
例1 テーブルのメタデータを得る
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
$meta = pg_meta_data($dbconn, 'authors');
if (is_array($meta)) {
echo '<pre>';
var_dump($meta);
echo '</pre>';
}
?>
上の例の出力は以下となります。
array(3) {
["author"]=>
array(5) {
["num"]=>
int(1)
["type"]=>
string(7) "varchar"
["len"]=>
int(-1)
["not null"]=>
bool(false)
["has default"]=>
bool(false)
}
["year"]=>
array(5) {
["num"]=>
int(2)
["type"]=>
string(4) "int2"
["len"]=>
int(2)
["not null"]=>
bool(false)
["has default"]=>
bool(false)
}
["title"]=>
array(5) {
["num"]=>
int(3)
["type"]=>
string(7) "varchar"
["len"]=>
int(-1)
["not null"]=>
bool(false)
["has default"]=>
bool(false)
}
}
| バージョン | 説明 |
|---|---|
| 5.6.0 |
実験的な関数ではなくなりました。デフォルト属性として "is enum" が追加されました。
extended フラグが追加されました。
|