Esempio n. 1
0
 function setup()
 {
     if ($this->isType('mysql')) {
         if ($this->getCreateTarget() == true) {
             $this->connection =& NewADOConnection($this->dbConfig->getDBType());
             $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getRootUserName(), $this->dbConfig->getRootPassword());
             if (!$ok) {
                 throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']);
             }
             // Drop database if already exists
             $sql = "drop database IF EXISTS " . $this->dbConfig->getDatabaseName();
             $result = $this->connection->Execute($sql);
             $this->checkError($result, $sql);
             $sql = 'create database ' . $this->dbConfig->getDatabaseName();
             if ($this->supportUTF8 == true) {
                 $sql .= " default character set utf8 default collate utf8_general_ci";
             }
             $result = $this->connection->Execute($sql);
             $this->checkError($result, $sql);
             $this->connection->Close();
         }
         $this->connection =& NewADOConnection($this->dbConfig->getDBType());
         $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getUserName(), $this->dbConfig->getPassword(), $this->dbConfig->getDatabaseName());
         if (!$ok) {
             throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']);
         }
         $result = $this->connection->_Execute("SET interactive_timeout=28800", false);
         $result = $this->connection->_Execute("SET wait_timeout=28800", false);
         $result = $this->connection->_Execute("SET net_write_timeout=900", false);
     }
 }
Esempio n. 2
0
 public function startBackup()
 {
     $this->writeLine('-- Dump generated by vtigerCRM');
     $this->writeLine('-- Date: ' . date("D, M j, G:i:s T Y"));
     $this->writeLine('-- HOST: ' . $this->dbConfig->getHostName() . ' Database: ' . $this->dbConfig->getDatabaseName());
     $this->writeLine("-- ----------------------------------");
     $this->writeLine("");
     $this->writeLine("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;");
     $this->writeLine("/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;");
     $this->writeLine("/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;");
     $this->writeLine("/*!40101 SET NAMES utf8 */;");
     $this->writeLine("/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;");
     $this->writeLine("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;");
     $this->writeLine("/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;");
     $this->writeLine("/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;");
 }
Esempio n. 3
0
 /**
  *
  * @param DatabaseConfig $config
  * @return DatabaseConfig
  */
 public static function getInstanceFromOtherConfig($config)
 {
     $newConfig = new DatabaseConfig($config->getHostName(), $config->getUsername(), $config->getPassword(), $config->getDatabaseName(), $config->getDBType(), $config->getRootUsername(), $config->getRootUsername());
     return $newConfig;
 }