From f1965971a389c8feb3c0f9818c9898b733bdd225 Mon Sep 17 00:00:00 2001 From: chriskl Date: Wed, 7 May 2003 15:00:56 +0000 Subject: [PATCH] heaps of 7.1 fixes --- classes/database/Postgres.php | 41 ++++++++++----------------------- classes/database/Postgres72.php | 36 ++++++++++++++++------------- 2 files changed, 32 insertions(+), 45 deletions(-) diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 7b4a5d01..20c50a5d 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres.php,v 1.95 2003/05/07 06:29:54 chriskl Exp $ + * $Id: Postgres.php,v 1.96 2003/05/07 15:00:56 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -265,16 +265,8 @@ class Postgres extends BaseDB { * @return -99 error */ function hasObjectID($table) { - $this->clean($table); - - $sql = "SELECT relhasoids FROM pg_class WHERE relname='{$table}'"; - - $rs = $this->selectSet($sql); - if ($rs->recordCount() != 1) return -99; - else { - $rs->f['relhasoids'] = $this->phpBool($rs->f['relhasoids']); - return $rs->f['relhasoids']; - } + // 7.0 and 7.1 always had an oid column + return true; } /** @@ -491,7 +483,7 @@ class Postgres extends BaseDB { pg_class c, pg_type t WHERE - c.relname = '{$table}' AND a.attname='{$column}' AND a.attrelid = c.oid AND a.atttypid = t.oid + c.relname = '{$table}' AND a.attname='{$field}' AND a.attrelid = c.oid AND a.atttypid = t.oid ORDER BY a.attnum"; } @@ -1203,25 +1195,16 @@ class Postgres extends BaseDB { } /** - * Grabs a list of indicies in the database or table - * @param $table (optional) The name of a table to get the indicies for + * Grabs a list of indexes for a table + * @param $table The name of a table whose indexes to retrieve + * @return A recordset */ - function &getIndicies($table = '') { + function &getIndexes($table = '') { $this->clean($table); - - $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid) - FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i - WHERE c.oid = '16977' AND c.oid = i.indrelid AND i.indexrelid = c2.oid - ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname"; - - - if ($table != '') - $where = "WHERE relname='{$table}' AND "; - elseif (!$this->_showSystem) - $where = "WHERE relname NOT LIKE 'pg_%' AND "; - else $where = ''; - - $sql = "SELECT relname FROM pg_class {$where} relkind ='i' ORDER BY relname"; + $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_get_indexdef(i.indexrelid) + FROM pg_class c, pg_class c2, pg_index i + WHERE c.relname = '{$table}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid + ORDER BY c2.relname"; return $this->selectSet($sql); } diff --git a/classes/database/Postgres72.php b/classes/database/Postgres72.php index e34e8a4a..f54f6d16 100644 --- a/classes/database/Postgres72.php +++ b/classes/database/Postgres72.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres72.php,v 1.40 2003/05/07 06:41:47 chriskl Exp $ + * $Id: Postgres72.php,v 1.41 2003/05/07 15:00:56 chriskl Exp $ */ @@ -45,6 +45,25 @@ class Postgres72 extends Postgres71 { // Table functions + /** + * Checks to see whether or not a table has a unique id column + * @param $table The table name + * @return True if it has a unique id, false otherwise + * @return -99 error + */ + function hasObjectID($table) { + $this->clean($table); + + $sql = "SELECT relhasoids FROM pg_class WHERE relname='{$table}'"; + + $rs = $this->selectSet($sql); + if ($rs->recordCount() != 1) return -99; + else { + $rs->f['relhasoids'] = $this->phpBool($rs->f['relhasoids']); + return $rs->f['relhasoids']; + } + } + /** * Retrieve the attribute definition of a table * @param $table The name of the table @@ -264,21 +283,6 @@ class Postgres72 extends Postgres71 { return $this->createFunction($funcname, $args, $returns, $definition, $language, $flags, true); } - /** - * Grabs a list of indexes for a table - * @param $table The name of a table whose indexes to retrieve - * @return A recordset - */ - function &getIndexes($table = '') { - $this->clean($table); - $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_get_indexdef(i.indexrelid) - FROM pg_class c, pg_class c2, pg_index i - WHERE c.relname = '{$table}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid - ORDER BY c2.relname"; - - return $this->selectSet($sql); - } - // Type functions /** -- 2.39.5