getSql() public method

Get the array of versions and SQL queries that would be executed for each version but do not execute anything.
public getSql ( string $to = null ) : array
$to string The version to migrate to.
return array $sql The array of SQL queries.
示例#1
0
 public function generateMigrationSql($return, &$hasMigrations)
 {
     $config = \Config::getInstance();
     $modules = $config->getActiveModules();
     $connection = $GLOBALS['container']['doctrine.connection.default'];
     $output = new OutputWriter();
     foreach ($modules as $module) {
         $path = sprintf('%s/system/modules/%s/migrations', TL_ROOT, $module);
         if (is_dir($path)) {
             $namespace = preg_split('~[\\-_]~', $module);
             $namespace = array_map('ucfirst', $namespace);
             $namespace = implode('', $namespace);
             $configuration = new Configuration($connection, $output);
             $configuration->setName($module);
             $configuration->setMigrationsNamespace('DoctrineMigrations\\' . $namespace);
             $configuration->setMigrationsDirectory($path);
             $configuration->registerMigrationsFromDirectory($path);
             $migration = new Migration($configuration);
             $versions = $migration->getSql();
             if (count($versions)) {
                 foreach ($versions as $version => $queries) {
                     if (count($queries)) {
                         $_SESSION['TL_CONFIRM'][] = sprintf($GLOBALS['TL_LANG']['doctrine']['migration'], $module, $version);
                         $hasMigrations = true;
                         $return = $this->appendQueries($return, $queries);
                     }
                 }
             }
         }
     }
     return $return;
 }