当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Migration::getMigrationClasses方法代码示例

本文整理汇总了PHP中Doctrine_Migration::getMigrationClasses方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Migration::getMigrationClasses方法的具体用法?PHP Doctrine_Migration::getMigrationClasses怎么用?PHP Doctrine_Migration::getMigrationClasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Migration的用法示例。


在下文中一共展示了Doctrine_Migration::getMigrationClasses方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     try {
         $migrationsPath = $this->getArgument('migrations_path');
         $modelsPath = $this->getArgument('models_path');
         $yamlSchemaPath = $this->getArgument('yaml_schema_path');
         $migration = new Doctrine_Migration($migrationsPath);
         $result1 = false;
         if (!count($migration->getMigrationClasses())) {
             $builder = new Doctrine_Migration_Builder($migration);
             $result1 = $builder->generateMigrationsFromModels($modelsPath);
         }
         $diff = new Doctrine_Migration_Diff($modelsPath, $yamlSchemaPath, $migration);
         $changes = $diff->generateMigrationClasses();
         $numChanges = count($changes, true) - count($changes);
         $result = $result1 || $numChanges ? true : false;
     } catch (Exception $e) {
         $result = false;
     }
     if (!$result) {
         throw new Doctrine_Task_Exception('Could not generate migration classes from models' . (isset($e) ? ': ' . $e->getMessage() : null));
     } else {
         $this->notify('Generated migration classes successfully from models');
     }
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:25,代码来源:GenerateMigrationsModels.php

示例2: execute

 public function execute()
 {
     try {
         $migrationsPath = $this->getArgument('migrations_path');
         $yamlSchemaPath = $this->getArgument('yaml_schema_path');
         $migration = new Doctrine_Migration($migrationsPath);
         $result1 = false;
         if (!count($migration->getMigrationClasses())) {
             $result1 = Doctrine_Core::generateMigrationsFromDb($migrationsPath);
         }
         $connections = array();
         foreach (Doctrine_Manager::getInstance() as $connection) {
             $connections[] = $connection->getName();
         }
         $changes = Doctrine_Core::generateMigrationsFromDiff($migrationsPath, $connections, $yamlSchemaPath);
         $numChanges = count($changes, true) - count($changes);
         $result = $result1 || $numChanges ? true : false;
     } catch (Exception $e) {
         $result = false;
     }
     if (!$result) {
         throw new Doctrine_Task_Exception('Could not generate migration classes from database');
     } else {
         $this->notify('Generated migration classes successfully from database');
     }
 }
开发者ID:hunde,项目名称:bsc,代码行数:26,代码来源:GenerateMigrationsDb.php

示例3: testMigration

 public function testMigration()
 {
     $migration = new Doctrine_Migration('migration_classes');
     $this->assertFalse($migration->hasMigrated());
     $migration->setCurrentVersion(3);
     $migration->migrate(0);
     $this->assertEqual($migration->getCurrentVersion(), 0);
     $this->assertEqual($migration->getLatestVersion(), 11);
     $this->assertEqual($migration->getNextVersion(), 12);
     $current = $migration->getCurrentVersion();
     $migration->setCurrentVersion(100);
     $this->assertEqual($migration->getCurrentVersion(), 100);
     $migration->setCurrentVersion($current);
     $migration->migrate(3);
     $this->assertTrue($migration->hasMigrated());
     $this->assertEqual($migration->getCurrentVersion(), 3);
     $this->assertTrue($this->conn->import->tableExists('migration_phonenumber'));
     $this->assertTrue($this->conn->import->tableExists('migration_user'));
     $this->assertTrue($this->conn->import->tableExists('migration_profile'));
     $migration->migrate(4);
     $this->assertFalse($this->conn->import->tableExists('migration_profile'));
     $migration->migrate(0);
     $this->assertEqual($migration->getCurrentVersion(), 0);
     $this->assertTrue($migration->getMigrationClass(1) instanceof AddPhonenumber);
     $this->assertTrue($migration->getMigrationClass(2) instanceof AddUser);
     $this->assertTrue($migration->getMigrationClass(3) instanceof AddProfile);
     $this->assertTrue($migration->getMigrationClass(4) instanceof DropProfile);
     $this->assertFalse($this->conn->import->tableExists('migration_phonenumber'));
     $this->assertFalse($this->conn->import->tableExists('migration_user'));
     $this->assertFalse($this->conn->import->tableExists('migration_profile'));
     $this->assertEqual(array(1 => 'AddPhonenumber', 2 => 'AddUser', 3 => 'AddProfile', 4 => 'DropProfile', 5 => 'Test5', 6 => 'Test6', 7 => 'Test7', 8 => 'Test8', 9 => 'Test9', 10 => 'Test10', 11 => 'Test11'), $migration->getMigrationClasses());
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:32,代码来源:MigrationTestCase.php

示例4: execute

 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $config = $this->getCliConfig();
     $migration = new Doctrine_Migration($config['migrations_path']);
     $from = $migration->getCurrentVersion();
     if (is_numeric($arguments['version'])) {
         $version = $arguments['version'];
     } else {
         if ($options['up']) {
             $version = $from + 1;
         } else {
             if ($options['down']) {
                 $version = $from - 1;
             } else {
                 $version = $migration->getLatestVersion();
             }
         }
     }
     if ($from == $version) {
         $this->logSection('doctrine', sprintf('Already at migration version %s', $version));
         return;
     }
     $this->logSection('doctrine', sprintf('Migrating from version %s to %s%s', $from, $version, $options['dry-run'] ? ' (dry run)' : ''));
     try {
         $migration_classes = $migration->getMigrationClasses();
         if ($version < $from) {
             for ($i = (int) $from - 1; $i >= (int) $version; $i--) {
                 $this->logSection('doctrine', 'executing migration : ' . $i . ', class: ' . $migration_classes[$i]);
                 $migration->migrate($i, $options['dry-run']);
             }
         } else {
             for ($i = (int) $from + 1; $i <= (int) $version; $i++) {
                 $this->logSection('doctrine', 'executing migration : ' . $i . ', class: ' . $migration_classes[$i]);
                 $migration->migrate($i, $options['dry-run']);
             }
         }
     } catch (Exception $e) {
     }
     // render errors
     if ($migration->hasErrors()) {
         if ($this->commandApplication && $this->commandApplication->withTrace()) {
             $this->logSection('doctrine', 'The following errors occurred:');
             foreach ($migration->getErrors() as $error) {
                 $this->commandApplication->renderException($error);
             }
         } else {
             $this->logBlock(array_merge(array('The following errors occurred:', ''), array_map(create_function('$e', 'return \' - \'.$e->getMessage();'), $migration->getErrors())), 'ERROR_LARGE');
         }
         return 1;
     }
     $this->logSection('doctrine', 'Migration complete');
 }
开发者ID:Phennim,项目名称:symfony1,代码行数:56,代码来源:sfDoctrineMigrateTask.class.php

示例5: testTest

 public function testTest()
 {
     $migration1 = new Doctrine_Migration(dirname(__FILE__) . '/DC221');
     $migration2 = new Doctrine_Migration(dirname(__FILE__) . '/DC221');
     $this->assertEqual($migration1->getMigrationClasses(), $migration2->getMigrationClasses());
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:6,代码来源:DC221TestCase.php

示例6: generateMigration

 public function generateMigration($className = null, $dFromDatabase = false, $mFromModels = false)
 {
     $this->_initDoctrineResource();
     $migratePath = $this->_getMigrationsDirectoryPath();
     if ($className) {
         Doctrine_Core::generateMigrationClass($className, $migratePath);
         $this->_print('Successfully generated migration class ' . $className . '.', array('color' => 'green'));
         $this->_print('Destination Directory: ' . $migratePath);
     } else {
         if ($dFromDatabase) {
             $yamlSchemaPath = $this->_getYamlDirectoryPath();
             $migration = new Doctrine_Migration($migrationsPath);
             $result1 = false;
             if (!count($migration->getMigrationClasses())) {
                 $result1 = Doctrine_Core::generateMigrationsFromDb($migrationsPath);
             }
             $connections = array();
             foreach (Doctrine_Manager::getInstance() as $connection) {
                 $connections[] = $connection->getName();
             }
             $changes = Doctrine_Core::generateMigrationsFromDiff($migrationsPath, $connections, $yamlSchemaPath);
             $numChanges = count($changes, true) - count($changes);
             $result = $result1 || $numChanges ? true : false;
             if ($result) {
                 $this->_print('Generated migration classes from the database successfully.');
             } else {
                 throw new Exception('Could not generate migration classes from database');
             }
         } else {
             if ($mFromModels) {
                 $this->_loadDoctrineModels();
                 Doctrine_Core::generateMigrationsFromModels($migrationsPath, null);
                 $this->_print('Generated migration classes from the model successfully.');
             }
         }
     }
 }
开发者ID:nabdoulm,项目名称:zf-doctrine,代码行数:37,代码来源:DoctrineProvider.php

示例7: PDO

 if (!$dbtable) {
     $sql = "CREATE DATABASE `" . $dbname . "` CHARACTER SET utf8;\n                CREATE USER '" . $config['db.user'] . "'@'localhost' IDENTIFIED BY '" . $config['db.pass'] . "';\n                GRANT ALL PRIVILEGES ON " . $dbname . ".* TO '" . $config['db.user'] . "'@'%' WITH GRANT OPTION;\n        ";
     $db->exec($sql);
 }
 $conn->close();
 $db = new PDO($config['db.dsn'], $config['db.user'], $config['db.pass']);
 $conn = Doctrine_Manager::connection($db);
 if (isset($google_user)) {
     echo 'user: ' . $google_user->getNickname() . '<br>';
 }
 $migration = new Doctrine_Migration(__DIR__ . '/classes', $conn);
 $migration->setTableName('doctrine_migration_version');
 if (isset($_REQUEST['ver']) && (!isset($google_user) || $google_user->getNickname() == 'piotr.podstawski@gammanet.pl')) {
     $version = 0 + intval($_REQUEST['ver']);
 } else {
     $classesKeys = array_keys($migration->getMigrationClasses());
     $version = 0 + array_pop($classesKeys);
 }
 if (isset($_SERVER['HTTP_HOST'])) {
     echo '<h1>';
 }
 if ($migration->getCurrentVersion() == $version) {
     echo 'Database at version ' . $version . PHP_EOL;
 } else {
     $migration->migrate($version);
     echo 'Migrated succesfully to version ' . $migration->getCurrentVersion() . PHP_EOL;
 }
 if (isset($_SERVER['HTTP_HOST'])) {
     echo '</h1>';
 }
 if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) {
开发者ID:podstawski,项目名称:papu,代码行数:31,代码来源:index.php


注:本文中的Doctrine_Migration::getMigrationClasses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。