Login   Register  
PHP Classes
elePHPant
Icontem

File: server/db.installer.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Oliver Lillie  >  PADL (PHP Application Distribution License System)  >  server/db.installer.php  >  Download  
File: server/db.installer.php
Role: Auxiliary script
Content type: text/plain
Description: SQL installer
Class: PADL (PHP Application Distribution License System)
Generate PHP application license keys
Author: By
Last change: Accessibility
Date: 2005-06-18 06:08
Size: 1,265 bytes
 

Contents

Class file image Download
<?php

    
function batchSQL ($script$id$errorsERR_STOP
    {
        
$errors = array();
        if (
is_null($script) || $script == "")
        {
            return 
false;
        }
        
$script str_replace (" --"" #"$script);
        
$script explode (";"$script);
        foreach (
$script as $command)
        {
            if ((!
$result=mysql_query($command$id)) && mysql_errno($id) != 1065
            {
                
$errors[] = mysql_error();
            }
            if (
mysql_errno ($id) != 1065
            {
                
$output $result;
            }
        }
        return (
count($errors) > 0) ? $errors $output;
    }

    function 
connect($table$user$pass$host='localhost')
    {
        
# connect to your servers DB
        
$id = @mysql_pconnect($host$user$pass);
        
# select the table required
        
@mysql_select_db($table$id);
        return 
$id;
    }
    
    function 
disconnect($id)
    {
        
# close the database
        
return @mysql_close($id);
    }
    
    include_once(
'db.config.php');
    
    
$id connect($table$user$pass);
    
$result batchSQL(file_get_contents('db.mysql.sql'), $id);
    
disconnect($id);
    
    if(
is_bool($result))
    {
        die(
'Successfull install of the distributionLicense sql was completed.');
    }
    else
    {
        echo 
'There were errors wth the sql install.<br /><br />';
        echo 
'<pre>';
        
print_r($result);
        echo 
'</pre>';
    }
    
?>