update : 2015.11.03
php.shukuma.com

검색:
 
 
Get meta data for table

pg_meta_data

(PHP 4 >= 4.3.0, PHP 5)

pg_meta_data Get meta data for table

설명

array pg_meta_data ( resource $connection , string $table_name [, bool $extended ] )

pg_meta_data() returns table definition for table_name as an array.

인수

connection

PostgreSQL database connection resource.

table_name

The name of the table.

extended

Flag for returning extended meta data. Default to FALSE.

반환값

An array of the table definition, or FALSE on error.

예제

Example #1 Getting table metadata

<?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 No longer experimental. Added "is enum" as default attribute. extended flag is added.

참고

  • pg_convert() - Convert associative array values into suitable for SQL statement