Reply to pqsql fieldnames

Your name:

Reply:


Posted by meltedown on 03/09/06 18:50

This is a function that returns the names a table field on a pgsql database

$skips is simply the field names that will be left out of the result.

This function acts differently on two different servers
Both servers have PHP Version 4.3.10-10ubuntu4.3
AND PostgreSQL(libpq) Version 7.4.6

On one server, the function acts as expected, returning an array with
the field names. On the other server, some of the field names come up 6
times instead of once. Apparently, something in my sql is creating
multiple values for some names. My sql is kind of fuzzy, can you see the
mistake ?

function fieldnames($table, $skips=NULL){
$sql="SELECT a.attname FROM pg_attribute a, pg_class c WHERE
c.relname = '$table' AND a.attnum > 0 AND a.attrelid = c.oid ORDER BY
a.attnum ";
$result=q($sql);
$skips=mkarr($skips);
while($row=pg_fetch_assoc($result)){
if(in_array($row['attname'], $skips))continue;
$fnames[]=$row['attname'];
}
return $fnames;
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация