Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Adam Globus-Hoenich  >  SQL Export  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example export
Class: SQL Export
Exports individual MySQL tables as SQL statements
Author: By
Last change:
Date: 2004-10-26 16:52
Size: 1,024 bytes
 

Contents

Class file image Download
<?php

    
//Test code for the SQL_Export class. Replace the values below with
    //the values for your database (password must be plain text)

    
$server "localhost:3306";    //Port is not really necessary
    
$username "root";        //Username for MySQL server
    
$password "";            //Password for MySQL server
    
$db "myDB";            //Name of database

    //Connect to DB the old fashioned way and get the names of the tables on the server
    
$cnx mysql_connect($server$username$password) or die(mysql_error());
    
mysql_select_db($db$cnx) or die(mysql_error());
    
$tables mysql_list_tables($db) or die(mysql_error());

    
//Create a list of tables to be exported
    
$table_list = array();
    while(
$t mysql_fetch_array($tables))
    {
        
array_push($table_list$t[0]);
    }

    
//Instantiate the SQL_Export class
    
require("SQL_Export.php");
    
$e = new SQL_Export($server$username$password$db$table_list);
    
//Run the export
    
echo $e->export();

    
//Clean up the joint
    
mysql_close($e->cnx);
    
mysql_close($cnx);

?>