diff options
author | Brion Vibber <brion@pobox.com> | 2010-10-11 19:10:51 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-10-11 19:10:51 -0700 |
commit | 9364e446b1edf34c01202828ebb1e7eaf04b3871 (patch) | |
tree | b13ee2649a26fb10c5d416695698bb09990b96c7 /lib/mysqlschema.php | |
parent | d0dbedf3bb27dc87a53677a6eefdb0dd8e49e148 (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.php | 56 |
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"; } /** |