Пример #1
0
 /**
  * @param array $tables
  * @param       $mysqldump
  *
  * @return Symfony_Process_ProcessBuilder
  */
 protected function createProcessBuilder(array $tables, $mysqldump)
 {
     $processBuilder = Symfony_Process_ProcessBuilder::create()->setWorkingDirectory(untrailingslashit(ABSPATH))->setTimeout(3600)->setPrefix($mysqldump)->add('--force')->add('--user='******'--password='******'--add-drop-table');
     if ($this->options->isSkipLockTables()) {
         // Don't lock all tables for read.
         $processBuilder->add('--lock-tables=false');
     }
     if ($this->options->isSkipExtendedInsert()) {
         $processBuilder->add('--extended-insert=false');
     }
     $processBuilder->add($this->configuration->getDatabase());
     // Dump only specific tables
     foreach ($tables as $table) {
         $processBuilder->add($table);
     }
     if ($this->configuration->isSocket()) {
         $processBuilder->add('--socket=' . $this->configuration->getSocketPath());
     } else {
         $processBuilder->add('--host=' . $this->configuration->getHost());
         if (($port = $this->configuration->getPort()) !== null) {
             $processBuilder->add('--port=' . $port);
         }
     }
     return $processBuilder;
 }
Пример #2
0
 public function __construct(MWP_IncrementalBackup_Database_Configuration $configuration)
 {
     $this->configuration = $configuration;
     if (!extension_loaded('pdo_mysql')) {
         throw new MWP_IncrementalBackup_Database_Exception_ConnectionException("PDO extension is disabled.");
     }
     $options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC);
     $this->connection = new PDO(self::getDsn($this->configuration), $this->configuration->getUsername(), $this->configuration->getPassword(), $options);
 }
Пример #3
0
 public function __construct(MWP_IncrementalBackup_Database_Configuration $configuration)
 {
     $this->configuration = $configuration;
     if (!extension_loaded('pdo_mysql')) {
         throw new MWP_IncrementalBackup_Database_Exception_ConnectionException("PDO extension is disabled.");
     }
     $options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC);
     // Mute the constructor since this error doesn't get thrown as an exception, but as a PHP warning:
     // Warning:  PDO::__construct(): The server requested authentication method unknown to the client [mysql_old_password]
     $this->connection = @new PDO(self::getDsn($this->configuration), $this->configuration->getUsername(), $this->configuration->getPassword(), $options);
 }
Пример #4
0
 public function __construct(MWP_IncrementalBackup_Database_Configuration $configuration)
 {
     $this->configuration = $configuration;
     if (!extension_loaded('mysql')) {
         throw new MWP_IncrementalBackup_Database_Exception_ConnectionException("Mysql extension is not loaded.");
     }
     if ($configuration->isSocket()) {
         $this->connection = @mysql_connect(':' . $configuration->getSocketPath(), $configuration->getUsername(), $configuration->getPassword());
     } else {
         $host = $configuration->getHost();
         if ($configuration->getPort() !== null) {
             $host .= ':' . $configuration->getPort();
         }
         $this->connection = @mysql_connect($host, $configuration->getUsername(), $configuration->getPassword());
     }
     if (!is_resource($this->connection)) {
         throw new MWP_IncrementalBackup_Database_Exception_ConnectionException(mysql_error(), mysql_errno());
     }
     @mysql_set_charset($configuration->getCharset(), $this->connection);
     mysql_select_db($configuration->getDatabase(), $this->connection);
 }