Example #1
0
 public function execute()
 {
     $results = Doctrine::createDatabases();
     foreach ($results as $name => $result) {
         $msg = $result instanceof Exception ? 'Could not create database for connection: "' . $name . '." Failed with exception: ' . $result->getMessage() : $result;
         $this->notify($msg);
     }
 }
Example #2
0
 public function execute()
 {
     $results = Doctrine::createDatabases();
     foreach ($results as $dbName => $bool) {
         $msg = $bool ? 'Successfully created database named: "' . $dbName . '"' : 'Could not create database named: "' . $dbName . '"';
         $this->notify($msg);
     }
 }
 protected function createDB()
 {
     try {
         Doctrine::createDatabases();
     } catch (Exception $e) {
         //..ignore, the db already exists
     }
 }
 public function doctrineAction()
 {
     $options = array('phpDocPackage' => 'Kromatick', 'phpDocSubpackage' => 'Intermodels', 'phpDocName' => 'Neozeratul', 'phpDocEmail' => '*****@*****.**');
     Doctrine::dropDatabases();
     Doctrine::createDatabases();
     Doctrine::generateModelsFromYaml(APPLICATION_PATH . "/data/schema/schema.yml", APPLICATION_PATH . "/models", $options);
     Doctrine::createTablesFromModels();
     //Doctrine::loadData($yamlPath, $append):
     echo Doctrine::generateSqlFromModels();
     $this->render('index');
 }
Example #5
0
 public function setUp()
 {
     $manager = Doctrine_Manager::getInstance();
     foreach ($manager as $conn) {
         $modelsPath = APPLICATION_PATH . '/models';
         $fixturesPath = APPLICATION_PATH . '/../doctrine/data/fixtures';
         $name = array($conn->getName());
         Doctrine::dropDatabases($name);
         Doctrine::createDatabases($name);
         Doctrine::createTablesFromModels($modelsPath);
         Doctrine::loadData($fixturesPath, true);
     }
 }
Example #6
0
 public function setUp()
 {
     try {
         //Load path configs
         $root_path = str_replace('test', '', dirname(__FILE__));
         $docCfg = Zend_Registry::get('config')->doctrine->toArray();
         foreach ($docCfg as &$cfg) {
             $cfg = str_replace("{ROOT_PATH}", $root_path, $cfg);
         }
         //Generate Database structure for tests
         $this->tearDown();
         Doctrine::createDatabases();
         Doctrine::createTablesFromModels($docCfg['models_path']);
         Doctrine::loadModel($docCfg['models_path']);
         Doctrine::loadData($docCfg['data_fixtures_path']);
         Util_Log::get()->UnitTests()->debug('Executed Env SetUp');
     } catch (Exception $e) {
         Util_Log::get()->UnitTests()->debug('Failed Setting up environment');
         Util_Log::get()->UnitTests()->err($e->getMessage());
     }
 }
Example #7
0
<?php

define("CLASSPATH", realpath(dirname(__FILE__) . "/../.."));
define("DOCTRINE_FOLDER", CLASSPATH . "/3rdParty/Doctrine-1.1.0/lib");
define("MODELS_FOLDER", CLASSPATH . "/models/data_objects");
define("YML_FOLDER", CLASSPATH . "/models/yml");
require_once DOCTRINE_FOLDER . '/Doctrine.php';
require_once CLASSPATH . '/config/db.conf.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
$conn = Doctrine_Manager::connection("{$db_conn_type}://{$db_user}:{$db_pass}@{$db_host}/{$db_name}", 'doctrine');
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::generateModelsFromYaml(YML_FOLDER . '/db.yml', MODELS_FOLDER);
Doctrine::createTablesFromModels(MODELS_FOLDER);
Example #8
0
 private function _freshInstall()
 {
     $defaultModules = Kohana::config('config.modules');
     Kohana::config_set('core.modules', $defaultModules);
     // Get the doctrine overlord
     $manager = Doctrine_Manager::getInstance();
     $conn = $manager->getCurrentConnection();
     try {
         // See if we can connect to the DB
         $conn->connect();
     } catch (Doctrine_Connection_Exception $e) {
         // We could connect earlier, hmmm....
         try {
             Doctrine::createDatabases();
         } catch (Exception $e) {
             // We cant resolve this issue without the user
             message::set('Unable to establish a connection to ' . $this->session->get('installer.dbName') . '! <div class="error_details">' . $e->getMessage() . '</div>');
             return FALSE;
         }
     }
     // See if the DB has any tables in it
     $tables = $conn->import->listTables();
     if (!empty($tables)) {
         // Yup, there are tables in our soon to be fresh install db, remove them
         try {
             $dsn = $conn->getOption('dsn');
             $dsn = $manager->parsePdoDsn($dsn);
             $tmpConn = $conn->getTmpConnection($dsn);
             $conn->close();
             $tmpConn->export->dropDatabase($dsn['dbname']);
             $tmpConn->export->createDatabase($dsn['dbname']);
             $manager->closeConnection($tmpConn);
             $conn->connect();
         } catch (Exception $e) {
             // We cant resolve this issue without the user
             message::set('Unable to recreate database ' . $this->session->get('installer.dbName') . '! <div class="error_details">' . $e->getMessage() . '</div>');
             return FALSE;
         }
     }
     $driver = $this->session->get('installer.tel_driver', 'none');
     kohana::log('debug', 'Installer running for driver ' . $driver);
     $packages = $this->session->get('installer.default_packages', array());
     $packages = arr::merge($this->minimumPackages, $packages, array($driver));
     try {
         $transaction = Package_Transaction::beginTransaction();
         foreach ($packages as $package) {
             try {
                 $identifier = Package_Catalog::getFirstAvaliablePackage($package);
                 $transaction->install($identifier);
             } catch (Exception $e) {
                 kohana::log('error', 'Error during initial install package selection: ' . $e->getMessage());
             }
         }
         $transaction->commit();
         Session::instance()->set('Bluebox_installer.created', Bluebox_Tenant::$created);
         return TRUE;
     } catch (Exception $e) {
         message::set('Installer Error!' . '<div class="error_details">' . $e->getMessage() . '</div>');
         return FALSE;
     }
 }