cvs: pear /DB package.xml /DB/DB pgsql.php

From: Date: Fri, 12 Jan 2007 02:10:40 +0000
Subject: cvs: pear /DB package.xml /DB/DB pgsql.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44184@lists.php.net to get a copy of this message
aharvey Fri Jan 12 02:10:40 2007 UTC Modified files: /pear/DB package.xml /pear/DB/DB pgsql.php Log: Added schema support to _pgFieldFlags. Fixes bug #5796 (Add Schema support to _pgFieldFlags in pgsql driver) and the related bug #7114 (Pgsql - incorrect results for schema). http://cvs.php.net/viewvc.cgi/pear/DB/package.xml?r1=1.215&r2=1.216&diff_format=u Index: pear/DB/package.xml diff -u pear/DB/package.xml:1.215 pear/DB/package.xml:1.216 --- pear/DB/package.xml:1.215 Thu Jan 11 09:03:58 2007 +++ pear/DB/package.xml Fri Jan 12 02:10:40 2007 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> <package version="1.0"> - <!-- $Id: package.xml,v 1.215 2007/01/11 09:03:58 aharvey Exp $ --> + <!-- $Id: package.xml,v 1.216 2007/01/12 02:10:40 aharvey Exp $ --> <name>DB</name> <summary>Database Abstraction Layer</summary> <description> @@ -97,6 +97,9 @@ * Altered connect() to handle non-standard ports. Thanks to Lukas Smith for the patch. Bug 7216. * Altered numRows() to properly restore last_query state. Bug 4388. + +pgsql: +* Added schema support to _pgFieldFlags. Bug 5796. ]]></notes> <filelist> <file name="DB.php" role="php" baseinstalldir="/"> http://cvs.php.net/viewvc.cgi/pear/DB/DB/pgsql.php?r1=1.131&r2=1.132&diff_format=u Index: pear/DB/DB/pgsql.php diff -u pear/DB/DB/pgsql.php:1.131 pear/DB/DB/pgsql.php:1.132 --- pear/DB/DB/pgsql.php:1.131 Thu Jan 11 07:43:09 2007 +++ pear/DB/DB/pgsql.php Fri Jan 12 02:10:40 2007 @@ -21,7 +21,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: pgsql.php,v 1.131 2007/01/11 07:43:09 aharvey Exp $ + * @version CVS: $Id: pgsql.php,v 1.132 2007/01/12 02:10:40 aharvey Exp $ * @link http://pear.php.net/package/DB */ @@ -970,22 +970,33 @@ { $field_name = @pg_fieldname($resource, $num_field); + // Check if there's a schema in $table_name and update things + // accordingly. + $from = 'pg_attribute f, pg_class tab, pg_type typ'; + if (strpos($table_name, '.') !== false) { + $from .= ', pg_namespace nsp'; + list($schema, $table) = explode('.', $table_name); + $tableWhere = "tab.relname = '$table' AND tab.relnamespace = nsp.oid AND nsp.nspname = '$schema'"; + } else { + $tableWhere = "tab.relname = '$table_name'"; + } + $result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef - FROM pg_attribute f, pg_class tab, pg_type typ + FROM $from WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid AND f.attname = '$field_name' - AND tab.relname = '$table_name'"); + AND $tableWhere"); if (@pg_numrows($result) > 0) { $row = @pg_fetch_row($result, 0); $flags = ($row[0] == 't') ? 'not_null ' : ''; if ($row[1] == 't') { $result = @pg_exec($this->connection, "SELECT a.adsrc - FROM pg_attribute f, pg_class tab, pg_type typ, pg_attrdef a + FROM $from, pg_attrdef a WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid AND f.attrelid = a.adrelid AND f.attname = '$field_name' - AND tab.relname = '$table_name' AND f.attnum = a.adnum"); + AND $tableWhere AND f.attnum = a.adnum"); $row = @pg_fetch_row($result, 0); $num = preg_replace("/'(.*)'::\w+/", "\\1", $row[0]); $flags .= 'default_' . rawurlencode($num) . ' '; @@ -994,12 +1005,12 @@ $flags = ''; } $result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey - FROM pg_attribute f, pg_class tab, pg_type typ, pg_index i + FROM $from, pg_index i WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid AND f.attrelid = i.indrelid AND f.attname = '$field_name' - AND tab.relname = '$table_name'"); + AND $tableWhere"); $count = @pg_numrows($result); for ($i = 0; $i < $count ; $i++) {

« previous php.pear.cvs (#44184) next »