PHP Classes
elePHPant
Icontem

File: _setups.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Wayne Philip  >  SQL Bulk Importer  >  _setups.php  >  Download  
File: _setups.php
Role: Configuration script
Content type: text/plain
Description: Setup file containing user settable parameters
Class: SQL Bulk Importer
Execute MySQL queries read from files
Author: By
Last change:
Date: 4 years ago
Size: 7,268 bytes
 

Contents

Class file image Download
<?php
session_start
;
// set the vars here
$this_path = '/Volumes/www/root/sd/nmc'; // (NO TRAILING '/'!!!!!!) where you text file are that you wish to import
$this_db = 'biznamib_nmcdata'; // database name
$this_user = 'root'; // "full access" user to the database
$this_server = 'localhost'; // server name or IP (If you have a port other thatn 31 state it with :xx after this)
$this_password = 'root'; // full access user password
$this_extention = 'csv'; // txt // etc but you must have a 3 letter extention // only fuiles with these extentions will be eveuated
$done_extention = '.done'; // completed files extention converter e.g. "12345.scv" will become "12345.csv.done" where complete
// the following variables are not for editing
$ht_results_opener = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
        <head>
        <meta name="keywords" content="openaxon.com,open,axon,namibia,windhoek,biznamibia.com,openaxon.com,open,axon,namibia,windhoek">
            <meta name="distribution" content="global">
            <meta http-equiv="cache-control" content="no-cache">
            <meta http-equiv="expires" content="3600">
            <meta name="revisit-after" content="1 days">
            <meta name="robots" content="index,follow">
            <meta name="publisher" content="Openaxon.Com">
            <meta name="copyright" content="Openaxon.Com">
            <title>Bulk MySql Importer</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <style type="text/css">
                @import "dom.css";
            </style>
</head>
<body>
<div id="forwho">
<ul>
    <li>
        If you need help read this..<a href="run_me_first.php"> Help (Instructions) Page </a>.
    </li>
</ul>


'
;
$ht_results_closer = '
    <ul>
        <li>
            If you need help read this..<a href="run_me_first.php"> Help (Instructions) Page </a>.
        </li>
    </ul>
    </div>
    </body>
    </html>'
;

$ht_index_opener = '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
        <head>
        <meta name="keywords" content="openaxon.com,open,axon,namibia,windhoek,biznamibia.com,openaxon.com,open,axon,namibia,windhoek">
            <meta name="distribution" content="global">
            <meta http-equiv="cache-control" content="no-cache">
            <meta http-equiv="expires" content="3600">
            <meta name="revisit-after" content="1 days">
            <meta name="robots" content="index,follow">
            <meta name="publisher" content="Openaxon.Com">
            <meta name="copyright" content="Openaxon.Com">
            <title>Bulk MySql Importer</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <style type="text/css">
                @import "dom.css";
            </style>
</head>
<body>
<div id="forwho">
    <h1>So what is this ?</h1>
    <ul>
        <li>
            This utility will take large (regular live usage of up to 3.2 Gb) text files containing Sql Statements
            (Insert, Delete, Update, Create etc) and execute them in a controlled way against a MySql database.
        </li>
        <li>
            I use, latest versions of, MySql and PHP in LAMP (Linux ; Apache ; MySql ; PHP) in a Dev/Test setting and am a
            <a href="http://hostmonster.com" target="_blank">Hostmonster</a> Client/Provider for the Live sites.
        </li>
        <li>
            I built this "importer" or "porter" because I often have issues around importing bulk data for very live sites with
            large databases and keeping environments in sync where I cannot trickle data between servers.
        </li>
        <li>
            As a free lancer I use remote hosting and need to keeping remote (live) and local (Dev/Test) databases in sync.
            This usually works very well manually until certain volumes are achieved.
        </li>
        <li>
            I also often get these wonderful Microsoft spreadsheets that have ooooodles of data that I need to import for somebody.
            I usually create and export an "out-file.txt" file that contains SQL Insert or Update statements and save it as text
            for this utility.
        </li>
        <li>
            I make use of all the normal forums etc.. including
            <a href="http://www.phpclasses.org" target="_blank">PHP Classes</a>
            where you probably got this.
        </li>
        <li>
            Please use anything but IE (any version) for doing this stuff. Why? It Sucks!
        </li>
    </ul>
    <h1> Who this is for</h1>
    <ul>
        <li>
            This is primarily for PHP and MySql developers and dbAdmins doing what I described above.
        </li>
        <li>
            Error trapping is kept to a minimum. Read the code it&prime;s actually for you.
        </li>
        <li>
            This page is the ONLY DOCUMENTATION.
        </li>
    </ul>
    <h1> How, What, Where, Usage, Results?</h1>
    <ul>
        <li>
            If you are reading this you have executed the <b>run_me_first.php</b> script. A good start.
        </li>
        <li>
            The files are listed here:
                <br>1. <b>_setups.php</b> does what it says. It contains the most important variables you need to edit.
                <br>Change those you need to..make a backup if you feel the need
                <br>2. <b>importer.php</b> does what it says - it imports the text files .This is the main script.
                <br>No Change should be needed.
                <br>3. <b>_to_db_class.php</b> This is used by importer.php and is the heart of the activity.
                <br>No Change should be needed.
                <br> NB --> look at the comment regarding windows machines in the <b>function process_file($file)</b> section
                -- about line 123. You need to read files in binary mode so use "rb". The line to edit is:<br>
                <br>
                <b>if ($handle = fopen($file,&prime;r&prime;)) </b>
                <br>
                change it to read : <b>if ($handle = fopen($file,&prime;rb&prime;))</b>
                <br>
                <b>NB!</b> do this only if the text import files were created on Windows or similar(?) machine.
                <br>hope that helped....!!
                <br>4. <b>test.csv</b>. This is a sample import file (Originating from an xls spreadsheet). It will create a table and import some data to it.<br>
        </li>
        <li>
                Try the application with the file I have provided (test.csv). It will do stuff including creating a table.<br>
                It will be renamed to <b>test.csv.done</b>. To re-use it rename it to <b>test.csv</b>
                <br><br>
                <b><u>Do all testing in an environment you have full access to.</b></u>
                <br><br>Happy Hunting..
        </li>
    </ul>
    <h1>Guarantees &amp; Execution &amp; Me </h1>
    <ul>
        <li>
            I absolutely guarantee that I have done my best on this - It may not be good enough! That is my only guarantee.
        </li>
        <li>
            Any other guarantee others may want to give is welcomed but not extended. -- Use Discriminately -- Use and modify freely.
        </li>
        <li>
            If you are happy with the setups execute <a href="importer.php">here</a> ..
            or just run the "importer.php" script from your favourite browser. <br>
            OK.. OK.. IE (Internet Deplorer) if you really must!.
        </li>
        <li>
            My sites, Linux help (Ubuntu focussed) and contact info can be found on my own personal space -
            <a href="http://openaxon.com" target="_blank">OpenAxonDotCom.</a>
        </li>
    </ul>
</body>
</html>
'
;

?>