本文整理汇总了PHP中Doctrine_Connection::createDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Connection::createDatabase方法的具体用法?PHP Doctrine_Connection::createDatabase怎么用?PHP Doctrine_Connection::createDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Connection
的用法示例。
在下文中一共展示了Doctrine_Connection::createDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flushDatabase
/** Flush the database and reload base fixtures.
*
* @param bool $rebuild
* true: The database will be dropped and rebuilt.
* false: The method will try just to flush the data.
*
* Note that the first time flushDatabase() is called (per execution), the
* database will be rebuilt regardless of $rebuild.
*
* @return static
*/
public function flushDatabase($rebuild = false)
{
if ($this->_connection) {
/* The first time we run a test case, drop and rebuild the database.
*
* After that, we can simply truncate all tables for speed.
*/
if (empty(self::$_dbRebuilt) or $rebuild) {
/* Don't try to drop the database unless it exists. */
$name = $this->getDatabaseName();
/** @noinspection PhpUndefinedFieldInspection */
if ($name and $this->_connection->import->databaseExists($name)) {
$this->_connection->dropDatabase();
}
$this->_connection->createDatabase();
Doctrine_Core::loadModels(sfConfig::get('sf_lib_dir') . '/model/doctrine', Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels());
self::$_dbRebuilt = true;
} else {
/* Determine the order we need to load models. */
if (!isset(self::$_dbFlushTree)) {
/** @noinspection PhpUndefinedFieldInspection */
$models = $this->_connection->unitOfWork->buildFlushTree(Doctrine_Core::getLoadedModels());
self::$_dbFlushTree = array_reverse($models);
}
$this->_doPreFlush();
/* Delete records, paying special attention to SoftDelete. */
foreach (self::$_dbFlushTree as $model) {
$table = Doctrine_Core::getTable($model);
if ($table->hasTemplate('SoftDelete')) {
/** @var $record Doctrine_Template_SoftDelete */
foreach ($table->createQuery()->execute() as $record) {
$record->hardDelete();
}
}
$table->createQuery()->delete()->execute();
$table->clear();
}
$this->_doPostFlush();
/** Clear all Doctrine table repositories to prevent memory leaks
* between tests.
*/
$this->_connection->clear();
}
}
return $this;
}