+ $this->appendAlterExtras($phrase, $tableName, $def);
+
+ if (count($phrase) > 0) {
+ $sql = 'ALTER TABLE ' . $tableName . ' ' . implode(",\n", $phrase);
+ $statements[] = $sql;
+ }
+
+ // Now create any indexes...
+ foreach ($indexes['mod'] + $indexes['add'] as $indexName) {
+ $this->appendCreateIndex($statements, $tableName, $indexName, $def['indexes'][$indexName]);
+ }
+
+ foreach ($fulltext['mod'] + $fulltext['add'] as $indexName) {
+ $colDef = $def['fulltext indexes'][$indexName];
+ $this->appendCreateFulltextIndex($statements, $tableName, $indexName, $colDef);
+ }
+
+ return $statements;
+ }
+
+ function diffArrays($oldDef, $newDef, $section, $compareCallback=null)
+ {
+ $old = isset($oldDef[$section]) ? $oldDef[$section] : array();
+ $new = isset($newDef[$section]) ? $newDef[$section] : array();
+
+ $oldKeys = array_keys($old);
+ $newKeys = array_keys($new);
+
+ $toadd = array_diff($newKeys, $oldKeys);
+ $todrop = array_diff($oldKeys, $newKeys);
+ $same = array_intersect($newKeys, $oldKeys);
+ $tomod = array();
+ $tokeep = array();
+
+ // Find which fields have actually changed definition
+ // in a way that we need to tweak them for this DB type.
+ foreach ($same as $name) {
+ if ($compareCallback) {
+ $same = call_user_func($compareCallback, $old[$name], $new[$name]);
+ } else {
+ $same = ($old[$name] == $new[$name]);
+ }
+ if ($same) {
+ $tokeep[] = $name;
+ continue;
+ }
+ $tomod[] = $name;
+ }
+ return array('add' => $toadd,
+ 'del' => $todrop,
+ 'mod' => $tomod,
+ 'keep' => $tokeep,
+ 'count' => count($toadd) + count($todrop) + count($tomod));