Revision: 31096
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 30, 2010 04:27 by barbelith
Initial Code
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', false); $databaseManager = new sfDatabaseManager($configuration); Doctrine_Core::loadModels(dirname(__FILE__).'/../../../lib/model'); $models = Doctrine::getLoadedModels(); $connections = array(); foreach ($models as $model) { $connections[Doctrine::getTable($model)->getConnection()->getName()][] = $model; } Doctrine_Manager::connection()->execute('SET FOREIGN_KEY_CHECKS = 0'); foreach ($connections as $connection => $models) { $models = Doctrine_Manager::getInstance()->getConnection($connection)->unitOfWork->buildFlushTree($models); $models = array_reverse($models); foreach ($models as $model) { Doctrine::getTable($model)->getConnection()->getDbh()->query("SET FOREIGN_KEY_CHECKS=0;"); Doctrine::getTable($model)->createQuery()->delete()->execute(); } } Doctrine_Core::loadData(sfConfig::get('sf_test_dir').'/fixtures'); Doctrine_Manager::connection()->execute('SET FOREIGN_KEY_CHECKS = 1');
Initial URL
Initial Description
Initial Title
Empty tables and reload data in Doctrine
Initial Tags
Initial Language
PHP