summaryrefslogtreecommitdiff
path: root/lib/mysqlschema.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-11 19:10:51 -0700
committerBrion Vibber <brion@pobox.com>2010-10-11 19:10:51 -0700
commit9364e446b1edf34c01202828ebb1e7eaf04b3871 (patch)
treeb13ee2649a26fb10c5d416695698bb09990b96c7 /lib/mysqlschema.php
parentd0dbedf3bb27dc87a53677a6eefdb0dd8e49e148 (diff)
Start reworking things to build create table stuff (can view via dumpschema.php --build)
Diffstat (limited to 'lib/mysqlschema.php')
-rw-r--r--lib/mysqlschema.php56
1 files changed, 6 insertions, 50 deletions
diff --git a/lib/mysqlschema.php b/lib/mysqlschema.php
index 9ccd502b5..a2ca835d9 100644
--- a/lib/mysqlschema.php
+++ b/lib/mysqlschema.php
@@ -244,59 +244,15 @@ class MysqlSchema extends Schema
}
/**
- * Creates a table with the given names and columns.
+ * Close out a 'create table' SQL statement.
*
- * @param string $name Name of the table
- * @param array $columns Array of ColumnDef objects
- * for new table.
- *
- * @return boolean success flag
+ * @param array $sql
+ * @param string $name
+ * @param array $def
*/
-
- public function createTable($name, $columns)
+ function appendCreateTableEnd(array &$sql, $name, array $def)
{
- $uniques = array();
- $primary = array();
- $indices = array();
-
- $sql = "CREATE TABLE $name (\n";
-
- for ($i = 0; $i < count($columns); $i++) {
-
- $cd =& $columns[$i];
-
- if ($i > 0) {
- $sql .= ",\n";
- }
-
- $sql .= $this->_columnSql($cd);
- }
-
- $idx = $this->_indexList($columns);
-
- if ($idx['primary']) {
- $sql .= ",\nconstraint primary key (" . implode(',', $idx['primary']) . ")";
- }
-
- foreach ($idx['uniques'] as $u) {
- $key = $this->_uniqueKey($name, $u);
- $sql .= ",\nunique index $key ($u)";
- }
-
- foreach ($idx['indices'] as $i) {
- $key = $this->_key($name, $i);
- $sql .= ",\nindex $key ($i)";
- }
-
- $sql .= ") ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; ";
-
- $res = $this->conn->query($sql);
-
- if (PEAR::isError($res)) {
- throw new Exception($res->getMessage());
- }
-
- return true;
+ $sql[] = ") ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin";
}
/**