說明
array
pg_meta_data ( resource connection, string table_name )
pg_metadata() 以陣列形式返回 table_name 表的定義。若果出錯則返回 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)
}
} |
|
警示 |
本函數是實驗性的。本函數的行為,內含函數名稱以及其它任何關於本函數的文件可能會在沒有知會的情況下隨
PHP 以後的發佈而改變。使用本函數風險自擔。 |
參見 pg_convert()。