本文整理汇总了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;
}
示例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();
}
示例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');
示例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;
}
}
}