PHP Classes
Icontem

File: server/db.installer.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet 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  
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
 

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>';
    }
    
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products