I have a php porgram which inserts data from an excel file to the mysql database but it doesn't work with files bigger than 4 MB and since I do not have access to the php.ini file I thought of chunking the insert statements. I found plupload but didn't figure out how to use it for insert statements. Any other method would be fine as well.
function insertRow($conn, $row, $header) {
// find indexes
// vorname
$firstNameIndex = array_search('vorname', $header, true);
// name / nachname
$lastNameIndex = array_search('name', $header, true);
if($lastNameIndex === false) $lastNameIndex = array_search('nachname', $header, true);
// anrede
$anredeIndex = array_search('anrede', $header, true);
// street
$streetIndex = array_search('straße', $header, true);
// Hausnummer
$hausnummerIndex = array_search('hausnummer', $header, true);
// Telefon
$telefonIndex = array_search('telefon', $header, true);
// PLZ
$plzIndex = array_search('plz', $header, true);
// ORT
$ortIndex = array_search('ort', $header, true);
$anrede = $row[$anredeIndex];
$firstName = $row[$firstNameIndex];
$lastName = $row[$lastNameIndex];
$street = $row[$streetIndex];
$houseNumber = $row[$hausnummerIndex];
$telefon = $row[$telefonIndex];
$plz = $row[$plzIndex];
$ort = $row[$ortIndex];
$title = 'unbekannt';
$geburtsdatum = 0;
$hnr_zusatz = "";
$timestamp = time();
$sql = <<<EOSQL
INSERT INTO adressen (anrede, vorname, nachname, strasse, hnr, telefon1, id_lieferung, priv_gew,
status, titel, geburtsdatum, hnr_zusatz, plz, ort, telefon2, mail, sperrung, sperrgrund, optin,
optindat, timestamp, zusatz1) VALUES ("$anrede", "$firstName", "$lastName", "$street",
"$houseNumber", "$telefon", 0, 0, 0, "$title", $geburtsdatum, "$hnr_zusatz", "$plz", "$ort", 0, "",
0, 0, 0, 0, $timestamp, 0);
EOSQL;
if (!$conn->query($sql) === TRUE) {
echo "Error: cant add this row " . $sql . "<br/>" . $conn->error;
print_r($row);
echo "___________________<br/>";
}
}
I know this isn't safe at all and I am open for sql injections but I will change that after this. Thank you in advance.