/** * initialize config * * create magic method config * * @param array * @return array */ public function updateConfig() { foreach ($this->_config as $name => $val) { $method = '__Set' . _camelize($name); if (method_exists($this, $method)) { $this->_config[$name] = call_user_func(array($this, $method), $val); } } return $this; }
function _single_migration($tmp, $step = NULL) { global $versions, $config; $version = $tmp; $migration = substr($version, strpos($version, '_') + 1); $migration = str_replace('.php', '', $migration); $migration = _camelize($migration); $at = array_sum(explode(" ", microtime())); echo "\n-- " . ($step != 'prev' ? "apply" : "revert") . " {$migration}\n"; include $config['directory'] . $version; $migration = new $migration(); $config['rollback'] = false; execute("START TRANSACTION;"); if ($step == 'next' || $step == NULL) { $migration->up(); if (empty($config['rollback'])) { if ($step !== NULL) { $config['schema'][] = $version; $config['schema'] = array_unique($config['schema']); _version($version); } } } else { $migration->down(); if (empty($config['rollback'])) { if (current($versions) === false) { @unlink('./schema/schema.php'); } else { $tmp = array_search(current($versions), $config['schema']); if ($tmp !== false) { unset($config['schema'][$tmp]); } _version(current($versions)); } } } execute(empty($config['rollback']) ? 'COMMIT;' : 'ROLLBACK;'); echo "\n-- completed in " . (array_sum(explode(" ", microtime())) - $at) . " --\n"; if (!empty($config['rollback'])) { exit; } }