Skip to content

Instantly share code, notes, and snippets.

@thyseus
Created April 18, 2018 07:50
Show Gist options
  • Save thyseus/38b99d14af97233e028b0ed2fdf77b3e to your computer and use it in GitHub Desktop.
Save thyseus/38b99d14af97233e028b0ed2fdf77b3e to your computer and use it in GitHub Desktop.
$shop_id = 246,
$sql = '';
if (($handle = fopen("DATEI.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$sql = sprintf('insert into ratings (comment, shop_id, score, import_date, rating_date)
values("%s", "%s", "%s", "%s", "%s")',
$data[4],
$shop_id,
$data[2],
date('Y-m-d G:i:s') # heutiges Datum (import_date)
date('Y-m-d G:i:s', $data[1]), # datum in der .csv (rating_date)) . "\n\n"
}
}
echo $sql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment