From 2d0807bc1c72c1351f57d7f65386ad7be9d19e83 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 8 Oct 2010 16:36:32 -0700 Subject: Starting on adapting postgresql schema class to look stuff up in the new drupalish format... Fetching basic column data and unique indexes. Still needs detail work, multi-value indexes, foreign keys, and distinguishing the primary key. Since we don't get comments and such, for cleaner comparisons we should probably do a filtering on supported features. --- lib/schema.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/schema.php') diff --git a/lib/schema.php b/lib/schema.php index 5868627ed..5085ab6fe 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -515,6 +515,17 @@ class Schema } } + /** + * Map a native type back to an independent type + size + * + * @param string $type + * @return array ($type, $size) -- $size may be null + */ + protected function reverseMapType($type) + { + return array($type, null); + } + /** * Convert an old-style set of ColumnDef objects into the current * Drupal-style schema definition array, for backwards compatibility @@ -590,6 +601,30 @@ class Schema $known = array('int', 'serial', 'numeric'); return in_array($type, $known); } + + /** + * Pull info from the query into a fun-fun array of dooooom + * + * @param string $sql + * @return array of arrays + */ + protected function fetchQueryData($sql) + { + $res = $this->conn->query($sql); + if (PEAR::isError($res)) { + throw new Exception($res->getMessage()); + } + + $out = array(); + $row = array(); + while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { + $out[] = $row; + } + $res->free(); + + return $out; + } + } class SchemaTableMissingException extends Exception -- cgit v1.2.3-54-g00ecf