當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Doctrine_Core::createDatabases方法代碼示例

本文整理匯總了PHP中Doctrine_Core::createDatabases方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Core::createDatabases方法的具體用法?PHP Doctrine_Core::createDatabases怎麽用?PHP Doctrine_Core::createDatabases使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine_Core的用法示例。


在下文中一共展示了Doctrine_Core::createDatabases方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _initDoctrine

 protected function _initDoctrine()
 {
     $config = $this->getOptions();
     $manager = Doctrine_Manager::getInstance();
     $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
     $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_CHARSET, 'utf8');
     $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_COLLATE, 'utf8_unicode_ci');
     $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_TYPE, 'INNODB');
     $manager->setAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM, true);
     $manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, false);
     $manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
     // enable validation on save()
     $manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
     $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
     if ($config['doctrine']['cache']) {
         $cacheDriver = new Doctrine_Cache_Apc();
         $manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver);
     }
     $conn = Doctrine_Manager::connection($config['doctrine']['dsn']);
     $conn->setCharset('utf8');
     try {
         Doctrine_Core::createDatabases();
     } catch (Exception $e) {
     }
     $conn = Doctrine_Core::loadModels(APPLICATION_PATH . '/models', Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     $conn = Doctrine_Core::createTablesFromModels();
     return $manager;
 }
開發者ID:kenncapara,項目名稱:emaxx,代碼行數:28,代碼來源:Bootstrap.php

示例2: setUp

 static function setUp()
 {
     try {
         Doctrine_Core::dropDatabases();
     } catch (Exception $e) {
     }
     Doctrine_Manager::connection()->clear();
     try {
         Doctrine_Core::createDatabases();
     } catch (Exception $e) {
     }
     Doctrine_Core::loadModels(APPLICATION_PATH . '/models', Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
     Doctrine_Core::createTablesFromModels();
 }
開發者ID:kenncapara,項目名稱:emaxx,代碼行數:14,代碼來源:bootstrap.php

示例3: realpath

<?php

$_test_dir = realpath(dirname(__FILE__) . '/..');
// configuration
require_once dirname(__FILE__) . '/../../../../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir . '/..'));
// autoloader
$autoload = sfSimpleAutoload::getInstance(sfConfig::get('sf_cache_dir') . '/project_autoload.cache');
$autoload->loadConfiguration(sfFinder::type('file')->name('autoload.yml')->in(array(sfConfig::get('sf_symfony_lib_dir') . '/config/config', sfConfig::get('sf_config_dir'))));
$autoload->register();
// lime
include $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
//Remove test dirs
$rootdir = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'test_root';
if (is_dir($rootdir)) {
    $files = sfFinder::type('any')->maxdepth(4)->in($rootdir);
    array_unshift($files, $rootdir);
    $fs = new sfFileSystem();
    $fs->remove($files);
}
new sfDatabaseManager($configuration);
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
Doctrine_Core::createTablesFromModels(sfConfig::get('sf_lib_dir') . '/model');
開發者ID:vjousse,項目名稱:lyMediaManagerPlugin,代碼行數:25,代碼來源:unit.php

示例4: syncdb

 public static function syncdb($apps = null, $drop_database = false, $append = true)
 {
     if (!self::$inited || !self::$connections) {
         self::init();
     }
     if (!$apps) {
         $apps = ini('base/INSTALLED_APPS');
     }
     if (!$apps) {
         return true;
     }
     if ($drop_database) {
         Doctrine_Core::dropDatabases();
         Doctrine_Core::createDatabases();
     }
     foreach ((array) $apps as $k => $app) {
         $app = str_replace('.', '/', $app);
         try {
             /*
              * Generate the models
              */
             if (isset($_GET['use_yaml'])) {
                 $schemas = Package::get_file(sprintf('applications/%s/%s', $app, 'schemas.yml'));
                 if (!is_file($schemas)) {
                     continue;
                 }
                 Doctrine_Core::generateModelsFromYaml($schemas, Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
             } else {
                 try {
                     import(sprintf('applications/%s/models/generated/*', $app));
                 } catch (DoesNotExistsException $e) {
                     continue;
                 }
             }
             /*
              * syncdb
              */
             Doctrine_Core::createTablesFromModels(Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
             /*
              * Insert test data
              */
             $dir = Package::get_folder(sprintf('applications/%s/fixtures', $app));
             if (is_dir($dir)) {
                 Doctrine_Core::loadData($dir, $append);
             }
         } catch (PDOException $e) {
             continue;
         }
     }
 }
開發者ID:uwitec,項目名稱:mgoa,代碼行數:50,代碼來源:doctrine.php


注:本文中的Doctrine_Core::createDatabases方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。