当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseCompatibilityUtil::restoreDatabase方法代码示例

本文整理汇总了PHP中DatabaseCompatibilityUtil::restoreDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseCompatibilityUtil::restoreDatabase方法的具体用法?PHP DatabaseCompatibilityUtil::restoreDatabase怎么用?PHP DatabaseCompatibilityUtil::restoreDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseCompatibilityUtil的用法示例。


在下文中一共展示了DatabaseCompatibilityUtil::restoreDatabase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDatabaseBackupAndRestore

 public function testDatabaseBackupAndRestore()
 {
     // Create new database (zurmo_wacky).
     if (RedBeanDatabase::getDatabaseType() == 'mysql') {
         $this->assertTrue(DatabaseCompatibilityUtil::createDatabase('mysql', $this->hostname, $this->rootUsername, $this->rootPassword, $this->databasePort, $this->temporaryDatabaseName));
         $connection = @mysql_connect($this->hostname . ':' . $this->databasePort, $this->rootUsername, $this->rootPassword);
         $this->assertTrue(is_resource($connection));
         @mysql_select_db($this->temporaryDatabaseName);
         @mysql_query("create table temptable (temptable_id int(11) unsigned not null)", $connection);
         @mysql_query("insert into temptable values ('5')", $connection);
         @mysql_query("insert into temptable values ('10')", $connection);
         $result = @mysql_query("SELECT count(*) from temptable");
         $totalRows = mysql_fetch_row($result);
         @mysql_close($connection);
         $this->assertEquals(2, $totalRows[0]);
         $this->assertTrue(DatabaseCompatibilityUtil::backupDatabase('mysql', $this->hostname, $this->rootUsername, $this->rootPassword, $this->temporaryDatabaseName, $this->databaseBackupTestFile));
         //Drop database, and restore it from backup.
         $this->assertTrue(DatabaseCompatibilityUtil::createDatabase('mysql', $this->hostname, $this->rootUsername, $this->rootPassword, $this->databasePort, $this->temporaryDatabaseName));
         $this->assertTrue(DatabaseCompatibilityUtil::restoreDatabase('mysql', $this->hostname, $this->rootUsername, $this->rootPassword, $this->temporaryDatabaseName, $this->databaseBackupTestFile));
         $connection = @mysql_connect($this->hostname . ':' . $this->databasePort, $this->rootUsername, $this->rootPassword);
         $this->assertTrue(is_resource($connection));
         @mysql_select_db($this->temporaryDatabaseName);
         $result = @mysql_query("SELECT count(*) from temptable");
         $totalRows = mysql_fetch_row($result);
         $result = @mysql_query("SELECT * from temptable");
         $rows1 = mysql_fetch_row($result);
         $rows2 = mysql_fetch_row($result);
         @mysql_close($connection);
         $this->assertEquals(2, $totalRows[0]);
         $this->assertEquals(5, $rows1[0]);
         $this->assertEquals(10, $rows2[0]);
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:33,代码来源:DatabaseCompatibilityUtilTest.php

示例2: restoreDatabase

 /**
  * Restore database from backup file.
  * Database must be empty before restore starts.
  * @param string $filePath
  * @param MessageStreamer $messageStreamer
  * @param $databaseType
  * @param $databaseHost
  * @param $databaseName
  * @param $databasePort
  * @param $databaseUsername
  * @param $databasePassword
  */
 protected function restoreDatabase($filePath, $messageStreamer, $databaseType, $databaseHost, $databaseName, $databasePort, $databaseUsername, $databasePassword)
 {
     $messageStreamer->add(Zurmo::t('Commands', 'Starting database restore process.'));
     $result = DatabaseCompatibilityUtil::restoreDatabase($databaseType, $databaseHost, $databaseUsername, $databasePassword, $databasePort, $databaseName, $filePath);
     if ($result) {
         $messageStreamer->add(Zurmo::t('Commands', 'Database restored.'));
     } else {
         $messageStreamer->add(Zurmo::t('Commands', 'There was an error during restore.'));
         $messageStreamer->add(Zurmo::t('Commands', 'Please restore database manually.'));
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:23,代码来源:DatabaseCommand.php


注:本文中的DatabaseCompatibilityUtil::restoreDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。