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);
     }
 }