(PHP 4 >= 4.3.0, PHP 5, PHP 7)
pg_meta_data — Retorna os metadados da tabela.
$connection
, string $table_name
) : array
pg_metadata() retorna a definição da tabela com o nome
igual ao valor de table_name como um array. Se houver
algum erro, retorna FALSE.
Exemplo #1 Obtendo os dados da tabela
<?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>';
}
?>
O exemplo acima irá mostar a seguinte saída:
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)
}
}
Esta função é EXPERIMENTAL. O comportamento, seu nome e documentação podem mudar sem aviso em futuras versões do PHP. Utilize por sua própria conta e risco.
Veja também pg_convert()