summaryrefslogtreecommitdiff
path: root/lib/schema.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-08 16:36:32 -0700
committerBrion Vibber <brion@pobox.com>2010-10-08 16:36:32 -0700
commit2d0807bc1c72c1351f57d7f65386ad7be9d19e83 (patch)
tree158de9dbf8294a3989c576023572aa0bf7ce912d /lib/schema.php
parentefa8ff82f4a364f6ba183a683431e9d83652cd9f (diff)
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.
Diffstat (limited to 'lib/schema.php')
-rw-r--r--lib/schema.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/schema.php b/lib/schema.php
index 5868627ed..5085ab6fe 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -516,6 +516,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
* with plugins written for 0.9.x.
@@ -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