WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform
Get meta data for table

pg_meta_data

(PHP 4 >= 4.3.0, PHP 5)

pg_meta_data Get meta data for table

Description

array pg_meta_data ( resource $connection , string $table_name )

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

Warning

This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk.

Parameters

connection

PostgreSQL database connection resource.

table_name

The name of the table.

Return Values

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

Examples

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>';
  }
?>

The above example will output:

 
 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) } } 

See Also