[Phplib-commit] CVS: php-lib-stable/php db_pgsql.inc,1.8,1.9
Brought to you by:
nhruby,
richardarcher
From: Richard A. <ric...@us...> - 2002-08-26 08:27:47
|
Update of /cvsroot/phplib/php-lib-stable/php In directory usw-pr-cvs1:/tmp/cvs-serv16440 Modified Files: db_pgsql.inc Log Message: Merging patch from Moritz Sinn to add extra functionality to pgsql metadata function. Index: db_pgsql.inc =================================================================== RCS file: /cvsroot/phplib/php-lib-stable/php/db_pgsql.inc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** db_pgsql.inc 25 Apr 2002 05:24:03 -0000 1.8 --- db_pgsql.inc 26 Aug 2002 08:27:43 -0000 1.9 *************** *** 154,182 **** } ! ! ! function metadata($table) { $count = 0; $id = 0; $res = array(); ! $this->connect(); ! $id = pg_exec($this->Link_ID, "select * from $table"); ! if ($id < 0) { ! $this->Error = pg_ErrorMessage($id); ! $this->Errno = 1; ! $this->halt("Metadata query failed."); } $count = pg_NumFields($id); ! for ($i=0; $i<$count; $i++) { $res[$i]["table"] = $table; ! $res[$i]["name"] = pg_FieldName ($id, $i); $res[$i]["type"] = pg_FieldType ($id, $i); $res[$i]["len"] = pg_FieldSize ($id, $i); $res[$i]["flags"] = ""; } ! ! pg_FreeResult($id); return $res; } --- 154,191 ---- } ! function metadata($table="") { $count = 0; $id = 0; $res = array(); ! if ($table) { ! $this->connect(); ! $id = pg_exec($this->Link_ID, "select * from $table"); ! if ($id < 0) { ! $this->Error = pg_ErrorMessage($id); ! $this->Errno = 1; ! $this->halt("Metadata query failed."); ! } ! } else { ! $id = $this->Query_ID; ! if (!$id) { ! $this->halt("No query specified."); ! } } + $count = pg_NumFields($id); ! for ($i=0; $i<$count; $i++) { $res[$i]["table"] = $table; ! $res[$i]["name"] = pg_FieldName ($id, $i); $res[$i]["type"] = pg_FieldType ($id, $i); $res[$i]["len"] = pg_FieldSize ($id, $i); $res[$i]["flags"] = ""; } ! ! if ($table) { ! pg_FreeResult($id); ! } ! return $res; } |