File: example.php

Recommend this page to a friend!
  Classes of Zakir Hyder  >  exportDb  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: exportDb
Create a MySQL database backup using mysqldump
Author: By
Last change:
Date: 12 years ago
Size: 1,072 bytes
 

Contents

Class file image Download
<?php
   
require("exportDb.php"); //the class file exportDb
   
   
$server = "localhost:3306"; //Port is not really necessary
   
$username = "user"; //Username for MySQL server
   
$password = "pass"; //Password for MySQL server
   
   
$e = new exportDb($server, $username, $password);
   
$myFile = $e->getFilename(); // getting file name
   
$e->backup(); // runing the backup
   
$e->close(); // close the mysql connection
   
unset($e);

   
//transfer file to another server
   
$FTP_HOST ="ftp.server.com";
   
$FTP_USER ="ftp_user";
   
$FTP_PW ="ftp_pass";
   
$FTP_ROOT_DIR="/public_html/db_backup/"; //to the folder the the file will be upload.

   
$mode = FTP_ASCII;
   
$conn_id = ftp_connect($FTP_HOST);
    if(
ftp_login($conn_id, $FTP_USER, $FTP_PW))
    {
       
ftp_pwd($conn_id);
       
ftp_pasv ( $conn_id, true );
       
ftp_chdir($conn_id,$FTP_ROOT_DIR);
       
ftp_pwd($conn_id);
       
       
$from = fopen($myFile,"r");
       
        if(
ftp_put($conn_id, $myFile, $myFile, $mode))
        {
          
        }
       
fclose($from);
    }
   
ftp_quit($conn_id);
   
?>


For more information send a message to info at phpclasses dot org.