echo "Create $table->name\n";
$pri_key = null;
- print_R($table);
$sql = array();
foreach ($table->fields as $f) {
if ($f->type == 'autoinc') {
$str = $this->computeFieldCreate($f);
$sql[] = $str;
}
- var_dump($pri_key);
- print_R($table);
if (is_array($table->keys)) {
foreach ($table->keys as $kn=>$k) {
- // if ($k->type != 'primary') continue;
- if ($pri_key !== null) continue;
+ if ($k->type != 'primary') continue;
+ // if ($pri_key !== null) continue;
$sql[] = "\tprimary key (" . join(', ', $k->fields) . ")";
}
}
- $xsql = "CREATE TABLE $table->name (\n" .
+ $sql = "CREATE TABLE $table->name (\n" .
join(",\n", $sql) .
")\n";
- echo $xsql;
+ echo $sql;
- $this->db->exec($xsql);
-
- if (is_array($table->keys)) foreach ($table->keys as $k) {
- if ($k->type == 'primary') continue;
- $this->db->exec($this->computeIndexCreate($table, $k));
- }
+ $this->db->exec($sql);
}
-
function alterTable(MTrackDBSchema_Table $from, MTrackDBSchema_Table $to)
{
$sql = array();