NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page MySQL Dump Script

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 10-05-2006, 10:47 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




MySQL Dump Script


This script returns the table structures of every table in every database.
To use just edit the variables at the top of the script.

If you find any bugs tell me. And yes, I will make it dump table contents sometime, lol

PHP Code:
<?php
set_time_limit
(0);
$db['host'] = '';
$db['user'] = '';
$db['pass'] = '';

function 
error($error_msg){
    die(
'<script>
????: NamePros.com http://www.namepros.com/code/244453-mysql-dump-script.html
    alert("An error occured!");
    alert("'
.$error_msg.'");
    </script>'
);
}

mysql_connect($db['host'],$db['user'],$db['pass'])or error(mysql_error());

$databases mysql_query('SHOW DATABASES;')or error(mysql_error());
$i=0;
while(
$i<mysql_num_rows($databases)){
    
mysql_select_db(mysql_result($databases,$i));
    
$tables=mysql_query('SHOW TABLES;')or error(mysql_error());
    echo 
'CREATE DATABASE `'.mysql_result($databases,$i).'`<br />';
    
$i2=0;
    while(
$i2<mysql_num_rows($tables)){
        
$fields=mysql_query('DESCRIBE `'.mysql_result($tables,$i2).'`;')or error(mysql_error());
        echo 
'CREATE TABLE `'.mysql_result($tables,$i2).'`(<br />';
        
$i3=0;
        while(
$i3<mysql_num_rows($fields)){
            echo 
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`'.mysql_result($fields,$i3,'field').'` '.mysql_result($fields,$i3,'type');
            if(
mysql_result($fields,$i3,'null') != 'NULL'){
                echo 
' NOT NULL';
                if(
mysql_result($fields,$i3,'default') != ''){
                    echo 
' DEFAULT \''.mysql_result($fields,$i3,'default').'\'';
                }
            }else{
                echo 
' DEFAULT NULL';
            }
            
            echo 
'<br />';
            
$i3++;
????: NamePros.com http://www.namepros.com/showthread.php?t=244453
        }
        echo 
')<br /><br />';
        
$i2++;
    }
    
$i++;
}
?>
Barrucadu is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 03:03 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger