Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
pat_mysql2file.php
Package: Generateur_v13.rar [view]
Upload User: feiyaoda
Upload Date: 2016-11-21
Package Size: 9556k
Code Size: 3k
Category:
WEB Mail
Development Platform:
PHP
- <?php
- function xmldumptable($table,$fp,$write_datas)
- {
- // header
- $content = "<table>n";
- $content .= " <definition>n";
- $content .= " <name>$table</name>n";
- $champs = mysql_query("SHOW FIELDS FROM $table");
- while ($champ = mysql_fetch_array($champs))
- {
- var_dump($champ);
- $fields[$champ[Field]]['type'] = $champ[Type];
- $is_null = ($champ['Null'] != "YES") ? "NOT NULL" : "NULL";
- $fields[$champ[Field]]['null'] = $is_null;
- $fields[$champ[Field]]['default'] = $champ['Default'];
- $content .= " <field>n";
- $content .= " <field_name>$champ[Field]</field_name>n";
- $content .= " <field_type>$champ[Type]</field_name>n";
- $content .= " <field_null>$is_null</field_null>n";
- $content .= " <field_default>$champ[Default]</field_default>n";
- $content .= " <field_extra>$champ[Extra]</field_extra>n";
- $content .= " </field>n";
- }
- @mysql_free_result($champs);
- $keys = mysql_query("SHOW KEYS FROM $table");
- while ($key = mysql_fetch_array($keys))
- {
- //var_dump($key);
- /*
- $kname=$key['Key_name'];
- if ($kname != "PRIMARY" and $key['Non_unique'] == 0)
- {
- $kname="UNIQUE|$kname";
- }
- if(!is_array($index[$kname]))
- {
- $index[$kname] = array();
- }
- $index[$kname][] = $key['Column_name'];
- */
- $fields[$key['Key_name']]['primary'] = $key['Key_name'];
- $fields[$key['Key_name']]['non_unique'] = $key['Non_unique'];
- }
- var_dump($fields);
- @mysql_free_result($keys);
- while(list($kname, $columns) = @each($index))
- {
- $tabledump .= ",n";
- $colnames=implode($columns,",");
- if($kname == "PRIMARY")
- {
- $content .= " PRIMARY KEY ($colnames)";
- }
- else
- {
- if (substr($kname,0,6) == "UNIQUE")
- {
- $kname=substr($kname,7);
- }
- $content .= " KEY $kname ($colnames)";
- }
- }
- $tabledump .= "n);nn";
- // Donn閑s - Data
- if ($write_datas)
- {
- $rows = mysql_query("SELECT * FROM $table");
- if (mysql_error()) echo mysql_error()."<br>n";
- $numfields = mysql_num_fields($rows);
- while ($row = mysql_fetch_array($rows))
- {
- $tabledump .= "INSERT INTO $table VALUES(";
- $cptchamp=-1;
- $firstfield=1;
- while (++$cptchamp<$numfields)
- {
- if (!$firstfield)
- {
- $tabledump.=",";
- }
- else
- {
- $firstfield=0;
- }
- if (!isset($row[$cptchamp]))
- {
- $tabledump .= "NULL";
- }
- else
- {
- $tabledump .= "'".mysql_escape_string($row[$cptchamp])."'";
- }
- }
- $tabledump .= ");n";
- }
- @mysql_free_result($rows);
- }
- return $content;
- }