host = $host; $this->db = $db; $this->user = $user; $this->pass = $pass; $this->conexao = @mysql_connect($this->host,$this->user,$this->pass); if (!$this->conexao) { echo "Não foi possível conectar-se ao Bando de Dados MySQL"; }else{ if (!@mysql_select_db($this->db,$this->conexao)) { echo "Banco de dados não encontrado"; } } } function cMysql(){ $database_server = 'localhost'; $database_user = 'root'; $database_password = 'senhadoroot'; $dbase = 'nomedobancodedados'; $this->connect($database_server, $dbase, $database_user, $database_password); } function disconnect(){ @mysql_close($this->conexao); } function free_page_result($recordset) { @mysql_free_result($recordset); } function mysql_list_tables($dbname) { $this->arrRecordset = @mysql_list_tables($dbname); return $this->arrRecordset; } function get_num_rows() { $this->num_rows = @mysql_num_rows($this->arrRecordset); return $this->num_rows; } function mysql_fetch_row($res) { $this->arrRecordset2 = @mysql_fetch_row($res); return $this->arrRecordset2; } function query ($sTipo, $sSql) { $this->sSql = $sSql; switch ($sTipo) { case "select":{ $this->arrRecordset = @mysql_query($this->sSql, $this->conexao) or die( @mysql_error('Erro ao executar o Select:')); } break; case "insert":{ $this->arrRecordset = @mysql_query($this->sSql, $this->conexao) or die( @mysql_error('Erro ao executar o Insert:')); } break; case "delete":{ $this->arrRecordset = @mysql_query($this->sSql, $this->conexao) or die( @mysql_error('Erro ao executar o Delete:')); } break; case "update":{ $this->arrRecordset = @mysql_query($this->sSql, $this->conexao) or die( @mysql_error('Erro ao executar o Update:')); } break; case "root":{ $this->arrRecordset = @mysql_query($this->sSql, $this->conexao) or die( @mysql_error('Erro ao executar o Acoes de Root:')); } break; } return $this->arrRecordset; } } function GeraXML($arquivo,$conteudo){ $xmlFile = $arquivo.".xml"; $fh = fopen('xml/'.$xmlFile, 'w') or die("can't open file"); $xmlTree = ''.$conteudo; fwrite($fh,$xmlTree); fclose($fh); } $qmedia = new cMysql; $res = $qmedia->mysql_list_tables('web_sips')//Informe o Nome do Banco; $registros = $qmedia->get_num_rows(); $row_title = ''; $conteudo = ''; for ($index=0; $index < $registros; ++$index) { $table = mysql_result ($res, $index, 0); $conteudo=""; $conteudo.="\n <".$table.">\n"; $res3 = $qmedia->query("select","SELECT * FROM ".$table); $registros2 = $qmedia->get_num_rows(); $numberfields = mysql_num_fields($res3); for ($i = 0; $i < $registros2; $i++){ $conteudo.="\n"; for ($j=0; $j<$numberfields ; $j++ ) { $var = mysql_field_name($res3, $j); $conteudo.="<".$var.">".mysql_result($res3, $i, $var)."\n"; } $conteudo.="\n"; } $conteudo.="\n"; GeraXML($table,$conteudo); } ?>