note 106695 deleted from function.pg-field-size by thiago
| From: | thiago@php.net | Date: | Tue, 29 Nov 2011 12:58:38 +0000 |
| Subject: | note 106695 deleted from function.pg-field-size by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184757@lists.php.net to get a copy of this message | ||
Note Submitter: gjc at aus3d dot com
----
RE: Postgress
//returns array of column names and types for table name
function GetColNamesTypes($table)
{
//echo "GetCols('{$table}')<br>";
$a = Array();
if ($table)
{
//$q = "SHOW COLUMNS FROM {$table}";
$q = "SELECT column_name,data_type FROM information_schema.columns WHERE table_name
='{$table}' ORDER BY ordinal_position";
//echo "q='{$q}'<br>";
$rs = $this->Exec($q);
if ($rs)
{
$num = pg_num_rows($rs);
$i = 0;
while ($row = pg_fetch_row($rs))
{
$a[$i][0] = $row[0];
$a[$i][1] = $row[1];
$i++;
}
pg_free_result($rs);
}
else
{
echo $this->utl->Err("Failed at GetCols($table)!");
}
}
return $a;
}