db = $db; $this->user = $user; $this->password = $password; $sa = explode(":", $server); $this->server = $sa[0]; $this->port = $sa[1]; unset($sa); $this->tables = $tables; $this->cnx = mysql_connect($this->server, $this->user, $this->password) or $this->error(mysql_error()); mysql_select_db($this->db, $this->cnx) or $this->error(mysql_error()); } function export() { foreach($this->tables as $t) { $this->table = $t; $header = $this->create_header(); $data = $this->get_data(); $this->$exported .= "###################\n# Dumping table $t\n###################\n\n$header" . $data . "\n"; } return($this->$exported); } function create_header() { $fields = mysql_list_fields($this->db, $this->table, $this->cnx); $h = "CREATE TABLE `" . $this->table . "` ("; for($i=0; $itable . "` WHERE 1", $this->cnx) or $this->error(mysql_error()); while($cr = mysql_fetch_array($data, MYSQL_NUM)) { $d .= "INSERT INTO `" . $this->table . "` VALUES ("; for($i=0; $iexport(); header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=backup.sql"); header("Pragma: no-cache"); header("Expires: 0"); echo $sql; ?>