(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
pg_meta_data — Get meta data for table
pg_meta_data(PgSql\Connection $connection, string $table_name, bool $extended = false): array|false
pg_meta_data() returns table definition for table_name as an array.
connectionAn PgSql\Connection instance.
table_nameThe name of the table.
extended Flag for returning extended meta data. Default to false.
| Version | Description |
|---|---|
| 8.1.0 | The connection parameter expects an PgSql\Connection instance now; previously, a resource was expected. |
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)
}
}
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/function.pg-meta-data.php