Revision: 6422
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 20, 2008 13:24 by mattkenefick
Initial Code
<?php
/**************************************
seesaw associates | http://seesaw.net
client:
file:
description:
Copyright (C) 2008 Matt Kenefick(.com)
**************************************/
ini_set("memory_limit","100M");
class expandSQL{
var $db;
function expandSQL($db){
$this->db = $db;
}
function expand($file){
$sql = $this->readFile($file);
foreach($sql as $query)
$db->query($query);
return true;
}
function readFile($filename){
$fileExt = $this->getext($filename);
if(file_exists($filename)){
$nLines = '';
switch( strtolower($fileExt) ){
case 'gz':
$lines = gzfile($filename);
break;
case 'sql':
$lines = readfile($filename);
break;
}
foreach($lines as $line) {
if(substr($line,1,1)!='-' && substr($line,1,1)!='')
$nLines .= $line;
}
return split(';',$nLines);
}
}
function getext($filename){
$ext = split('\.',$filename);
$ext = $ext[count($ext)-1];
return $ext;
}
}
?>
Initial URL
Initial Description
Expands a MySQL / Gzipped file and executes it's queries.
Initial Title
PHP Class: Expand MySQL File
Initial Tags
mysql, file
Initial Language
PHP