pg_meta_data
(PHP 4 >= 4.3.0, PHP 5)
pg_meta_data — 获得表的元数据
说明
  array <strong>pg_meta_data</strong>
   ( resource <code>$connection</code>
  , string <code>$table_name</code>
  )
<p>
 <strong>pg_metadata()</strong> 以数组形式返回 table_name 表的定义。
</p>
<strong>Warning</strong><p>此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的PHP 发布版本中未通知就被修改。使用本函数风险自担 。
参数
connection
      
PostgreSQL database connection resource.
table_name
      The name of the table.
返回值
   以数组 array 形式返回表的定义,如果出错则返回 FALSE。
  
范例
Example #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)
}
}
  
  参见
pg_convert() - 将关联的数组值转换为适合 SQL 语句的格式。