summaryrefslogtreecommitdiff
path: root/lib/schema.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/schema.php')
-rw-r--r--lib/schema.php58
1 files changed, 4 insertions, 54 deletions
diff --git a/lib/schema.php b/lib/schema.php
index a7f64ebed..137b814e0 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -75,65 +75,15 @@ class Schema
static function get()
{
+ $type = common_config('db', 'type');
if (empty(self::$_single)) {
- self::$_single = new Schema();
+ $schemaClass = ucfirst($type).'Schema';
+ self::$_single = new $schemaClass();
}
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.
*
* Throws an exception if the table is not found.
@@ -523,7 +473,7 @@ class Schema
} else {
$sql .= ($cd->nullable) ? "null " : "not null ";
}
-
+
if (!empty($cd->auto_increment)) {
$sql .= " auto_increment ";
}