summaryrefslogtreecommitdiff
path: root/lib/schema.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-01-31 15:20:57 -0500
committerEvan Prodromou <evan@status.net>2010-01-31 15:20:57 -0500
commitebf4e497f6e520b011a2a364a9a866fb2d7fb262 (patch)
tree6d8cd08a5b07cc3132e3c328b0bc6e76576c7ae0 /lib/schema.php
parent30268cff7899519f249861e067e3af680ee1c570 (diff)
parent22a6e46b45226647b6e7b9bfdc013e59c4a52428 (diff)
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Diffstat (limited to 'lib/schema.php')
-rw-r--r--lib/schema.php56
1 files changed, 4 insertions, 52 deletions
diff --git a/lib/schema.php b/lib/schema.php
index a7f64ebed..27a4deda1 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -75,63 +75,15 @@ class Schema
static function get()
{
+ $type = common_config('db', 'type');
if (empty(self::$_single)) {
- self::$_single = new Schema();
+ include "lib/schema.{$type}.php";
+ $class = $type.='Schema';
+ self::$_single = new $class();
}
return self::$_single;
}
- /**
- * Returns a TableDef object for the table
- * in the schema with the given name.
- *
- * Throws an exception if the table is not found.
- *
- * @param string $name Name of the table to get
- *
- * @return TableDef tabledef for that table.
- */
-
- public function getTableDef($name)
- {
- $res = $this->conn->query('DESCRIBE ' . $name);
-
- if (PEAR::isError($res)) {
- throw new Exception($res->getMessage());
- }
-
- $td = new TableDef();
-
- $td->name = $name;
- $td->columns = array();
-
- $row = array();
-
- while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
-
- $cd = new ColumnDef();
-
- $cd->name = $row['Field'];
-
- $packed = $row['Type'];
-
- if (preg_match('/^(\w+)\((\d+)\)$/', $packed, $match)) {
- $cd->type = $match[1];
- $cd->size = $match[2];
- } else {
- $cd->type = $packed;
- }
-
- $cd->nullable = ($row['Null'] == 'YES') ? true : false;
- $cd->key = $row['Key'];
- $cd->default = $row['Default'];
- $cd->extra = $row['Extra'];
-
- $td->columns[] = $cd;
- }
-
- return $td;
- }
/**
* Gets a ColumnDef object for a single column.