1
0
mirror of synced 2025-01-20 07:21:40 +03:00
This commit is contained in:
zYne 2007-05-18 09:30:29 +00:00
parent 9b470a642b
commit 4b09d95d0f

View File

@ -333,7 +333,7 @@ END;
case 'rename': case 'rename':
break; break;
default: default:
throw new Doctrine_Export_Exception('change type "'.$changeName.'" not yet supported'); throw new Doctrine_Export_Exception('change type "' . $changeName . '" not yet supported');
} }
} }
@ -343,41 +343,42 @@ END;
$name = $this->conn->quoteIdentifier($name, true); $name = $this->conn->quoteIdentifier($name, true);
if (!empty($changes['add']) && is_array($changes['add'])) { if ( ! empty($changes['add']) && is_array($changes['add'])) {
$fields = array(); $fields = array();
foreach ($changes['add'] as $field_name => $field) { foreach ($changes['add'] as $fieldName => $field) {
$fields[] = $this->conn->getDeclaration($field['type'], $field_name, $field); $fields[] = $this->conn->getDeclaration($field['type'], $fieldName, $field);
} }
$result = $this->conn->exec("ALTER TABLE $name ADD (". implode(', ', $fields).')'); $result = $this->conn->exec('ALTER TABLE ' . $name . ' ADD (' . implode(', ', $fields) . ')');
} }
if (!empty($changes['change']) && is_array($changes['change'])) { if ( ! empty($changes['change']) && is_array($changes['change'])) {
$fields = array(); $fields = array();
foreach ($changes['change'] as $field_name => $field) { foreach ($changes['change'] as $fieldName => $field) {
$fields[] = $field_name. ' ' . $this->conn->getDeclaration($field['definition']['type'], '', $field['definition']); $fields[] = $fieldName. ' ' . $this->conn->getDeclaration($field['definition']['type'], '', $field['definition']);
} }
$result = $this->conn->exec("ALTER TABLE $name MODIFY (". implode(', ', $fields).')'); $result = $this->conn->exec('ALTER TABLE ' . $name . ' MODIFY (' . implode(', ', $fields) . ')');
} }
if (!empty($changes['rename']) && is_array($changes['rename'])) { if ( ! empty($changes['rename']) && is_array($changes['rename'])) {
foreach ($changes['rename'] as $field_name => $field) { foreach ($changes['rename'] as $fieldName => $field) {
$field_name = $this->conn->quoteIdentifier($field_name, true); $query = 'ALTER TABLE ' . $name . ' RENAME COLUMN ' . $this->conn->quoteIdentifier($fieldName, true)
$query = "ALTER TABLE $name RENAME COLUMN $field_name TO ".$this->conn->quoteIdentifier($field['name']); . ' TO ' . $this->conn->quoteIdentifier($field['name']);
$result = $this->conn->exec($query); $result = $this->conn->exec($query);
} }
} }
if (!empty($changes['remove']) && is_array($changes['remove'])) { if ( ! empty($changes['remove']) && is_array($changes['remove'])) {
$fields = array(); $fields = array();
foreach ($changes['remove'] as $field_name => $field) { foreach ($changes['remove'] as $fieldName => $field) {
$fields[] = $this->conn->quoteIdentifier($field_name, true); $fields[] = $this->conn->quoteIdentifier($fieldName, true);
} }
$result = $this->conn->exec("ALTER TABLE $name DROP COLUMN ". implode(', ', $fields)); $result = $this->conn->exec('ALTER TABLE ' . $name . ' DROP COLUMN ' . implode(', ', $fields));
} }
if (!empty($changes['name'])) { if ( ! empty($changes['name'])) {
$change_name = $this->conn->quoteIdentifier($changes['name'], true); $changeName = $this->conn->quoteIdentifier($changes['name'], true);
$result = $this->conn->exec("ALTER TABLE $name RENAME TO ".$change_name); $result = $this->conn->exec('ALTER TABLE ' . $name . ' RENAME TO ' . $changeName);
} }
} }
/** /**