本文整理汇总了PHP中Doctrine::createDatabases方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::createDatabases方法的具体用法?PHP Doctrine::createDatabases怎么用?PHP Doctrine::createDatabases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine
的用法示例。
在下文中一共展示了Doctrine::createDatabases方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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);
}
}
示例2: execute
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);
}
}
示例3: createDB
protected function createDB()
{
try {
Doctrine::createDatabases();
} catch (Exception $e) {
//..ignore, the db already exists
}
}
示例4: doctrineAction
public function doctrineAction()
{
$options = array('phpDocPackage' => 'Kromatick', 'phpDocSubpackage' => 'Intermodels', 'phpDocName' => 'Neozeratul', 'phpDocEmail' => 'neozeratul@gmail.com');
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');
}
示例5: setUp
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);
}
}
示例6: setUp
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());
}
}
示例7: define
<?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);
示例8: _freshInstall
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;
}
}