Exemplo n.º 1
0
 /**
  * Restore database
  *
  * @param $inputFile
  * @return bool|string
  */
 public function restore($inputFile)
 {
     $tempFileHandle = tmpfile();
     fwrite($tempFileHandle, "[client]" . PHP_EOL . "user = '******'" . PHP_EOL . "password = '******'" . PHP_EOL . "host = '" . $this->host . "'" . PHP_EOL . "port = '" . $this->port . "'" . PHP_EOL);
     $temporaryCredentialsFile = stream_get_meta_data($tempFileHandle)['uri'];
     $command = sprintf('mysql --defaults-extra-file=%s %s < %s', escapeshellarg($temporaryCredentialsFile), escapeshellarg($this->database), escapeshellarg($inputFile));
     return $this->console->run($command);
 }
Exemplo n.º 2
0
 /**
  * Restore database
  *
  * @param $inputFile
  * @return bool|string
  */
 public function restore($inputFile)
 {
     $command = sprintf('PGPASSWORD=%s psql --host=%s --port=%s --user=%s %s -f %s', escapeshellarg($this->password), escapeshellarg($this->host), escapeshellarg($this->port), escapeshellarg($this->user), escapeshellarg($this->database), escapeshellarg($inputFile));
     //        Log::info($command);exit;
     return $this->console->run($command);
 }