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


PHP Doctrine_Connection::createDatabase方法代碼示例

本文整理匯總了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;
 }
開發者ID:todofixthis,項目名稱:sfJwtPhpUnitPlugin,代碼行數:58,代碼來源:Driver.class.php


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