Changeset 4310
- Timestamp:
- 04/30/08 17:19:40 (14 months ago)
- Files:
-
- 1 modified
-
branches/0.11/lib/Doctrine/Export.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/lib/Doctrine/Export.php
r4252 r4310 1070 1070 if ( ! isset($connections[$connectionName])) { 1071 1071 $connections[$connectionName] = array( 1072 'create_tables' => array(),1072 'create_tables' => array(), 1073 1073 'create_sequences' => array(), 1074 'alters' => array() 1074 'create_indexes' => array(), 1075 'alters' => array() 1075 1076 ); 1076 1077 } … … 1081 1082 // We need these to happen first 1082 1083 foreach ($sql as $key => $query) { 1083 if (strstr($query, 'CREATE TABLE')) { 1084 // If create table statement 1085 if (substr($query, 0, strlen('CREATE TABLE')) == 'CREATE TABLE') { 1084 1086 $connections[$connectionName]['create_tables'][] = $query; 1085 1087 1086 1088 unset($sql[$key]); 1089 continue; 1087 1090 } 1088 1091 1089 if (strstr($query, 'CREATE SEQUENCE')) { 1092 // If create sequence statement 1093 if (substr($query, 0, strlen('CREATE SEQUENCE')) == 'CREATE SEQUENCE') { 1090 1094 $connections[$connectionName]['create_sequences'][] = $query; 1091 1095 1092 1096 unset($sql[$key]); 1097 continue; 1098 } 1099 1100 // If create index statement 1101 if (preg_grep("/CREATE .* INDEX/", array($query))) { 1102 $connections[$connectionName]['create_indexes'][] = $query; 1103 1104 unset($sql[$key]); 1105 continue; 1106 } 1107 1108 // If alter table statement 1109 if (substr($query, 0, strlen('ALTER TABLE')) == 'ALTER TABLE') { 1110 $connections[$connectionName]['alters'][] = $query; 1111 1112 unset($sql[$key]); 1113 continue; 1093 1114 } 1094 1115 } 1095 1096 $connections[$connectionName]['alters'] = array_merge($connections[$connectionName]['alters'], $sql);1097 1116 } 1098 1117 1099 // Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom1118 // Loop over all the sql again to merge everything together so it is in the correct order 1100 1119 $build = array(); 1101 1120 foreach ($connections as $connectionName => $sql) { 1102 $build[$connectionName] = array_merge($sql['create_tables'], $sql['create_sequences'], $sql[' alters']);1121 $build[$connectionName] = array_merge($sql['create_tables'], $sql['create_sequences'], $sql['create_indexes'], $sql['alters']); 1103 1122 } 1104 1123