-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.php
44 lines (34 loc) · 1.61 KB
/
xml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include 'conexion.php';
$xml="";
$database = $_POST['param'];
$sql1 = "select * from `information_schema`.schemata where SCHEMA_NAME='".$database."'";
$sql2 = "select * from `information_schema`.`TABLES` where `TABLE_SCHEMA`='".$database."'";
$query1 = mysql_query($sql1, $con);
$query2 = mysql_query($sql2, $con);
$xml.="<?xml version='1.0' encoding='UTF-8'?>\n";
while($resultado = mysql_fetch_row($query1)){
$xml.="<database schema_name='".$resultado[1]."' default_character_set_name='".$resultado[2]."' default_collation_name='".$resultado[3]."'>\n";
while($resultado1 = mysql_fetch_row($query2)){
$xml.=" <tabla table_name='".$resultado1[2]."' engine='".$resultado1[4]."'>\n";
$sql3 = "select * from `information_schema`.`COLUMNS` where `TABLE_SCHEMA`='".$database."' AND table_name = '".$resultado1[2]."'";
$query3 = mysql_query($sql3, $con);
while($resultado2 = mysql_fetch_row($query3)){
if($resultado2[2] == $resultado1[2]){
$xml.=" <colum colum_name ='".$resultado2[3]."' data_type='".$resultado2[7]."' character_maximum_lenght='".$resultado2[8]."' colum_type='".$resultado2[14]."' colum_key='".$resultado2[15]."' extra='".$resultado2[16]."'></colum>\n";
}
}
$xml.=" </tabla>\n";
}
$xml.="</database>\n";
}
echo $xml;
// include"DB.php";
// $xml="";
// $database = $_POST['param'];
// $sql1 = "select * from `information_schema`.schemata where SCHEMA_NAME='".$database."'";
// $sql2 = "select * from `information_schema`.`TABLES` where `TABLE_SCHEMA`='".$database."'";
// $q = DB::get()->query($sql2, PDO::FETCH_ASSOC);
// foreach ($q as $campos){
// }
?>