Wow, that was quick :p
Computer details:
Pentium 4 2.88GHz
512 RAM
Seagate Barracuda HDD
CREATE TABLE businesstypelist (
businessID int(11) NOT NULL default '0',
orgID int(11) NOT NULL default '0',
PRIMARY KEY (businessID,orgID)
) TYPE=MyISAM;
Try adding a LOCK TABLE command before the series of inserts. This should stop index updates until you UNLOCK TABLE.
I will try that.
As forreading the CSV file, I do with this code:
$fp = fopen ("data/".$filename,"r");
while ($arrData = fgetcsv ($fp, 1000, ";"))
{
$i = $_SESSION['_i'];
$arrOrganization[$i][0] = $arrData[0];
.
.
$arrOrganization[$i][6] = $organisationForm;
So I put each field separeted by semicolon in an array.
This is in my dao.class.php file
csv_insert_into_table()
function csv_insert_into_table($strTableName, $arrFieldArray, $strCondition)
{
# TODO: Check to see if $arrFieldValues has equal number of fields as table
$arrFieldNames = $this->get_table_fieldnames($strTableName);
foreach ($arrFieldArray as $arrKey) {
$strFieldValues .= '"'.$arrKey.'",';
}
foreach ($arrFieldNames as $key) {
$strFieldNames .= $key.',';
}
$strFieldValues = substr($strFieldValues,0,-2);
$strFieldNames = substr($strFieldNames,0,-1);
$sqlQuery = ('insert into '.$strTableName.' ('.$strFieldNames.') values ('.$strFieldValues.'") ');
return $sqlQuery;
}
And in my csvpopulate.php file:
This one: run_query($arrBusinessCodes, 'businesstype', null) I only do ones. It just populates a table that is not frequently updated.
These however are executed every time I run the script:
### run queries and populate DB tables
run_query($arrOrganization, 'organisation', null);
run_query($arrAddress, 'address', null);
run_query($arrBusinessArea, 'businesstypelist', null);
run_query($arrPerson, 'person', $arrOrganization);
Just for the hell of it, and if you guys have the time to look them through, I have attached the two files 🙂