_host = $host; $this->_port = $port; $this->_user = $user; $this->_password = $password; $this->_db = $db; return $this; } /** * Set dumpfile path * @param string $path * @return $this */ public function setDumpFile($path) { $this->_dumpfile = $path; return $this; } /** * MySQL dump * @return bool */ public function mysqldump() { $command = "mysqldump -h{$this->_host} -P{$this->_port} -u{$this->_user} "; if (!empty($this->_password)) { $command .= "-p{$this->_password} "; } $command .= "{$this->_db} > {$this->_dumpfile}"; $output = []; $result = exec($command, $output); if (empty($result)) { chmod($this->_dumpfile, 0644); return true; } $this->error = $result; return false; } public function getDumpFile() { return $this->_dumpfile; } }