'; $vars = func_get_args(); foreach ($vars as $var) { echo '
'; if (is_scalar($var) || is_null($var)) { var_dump($var); } else { print_r($var); } echo ''; } echo '
'; print_r($backtrace); echo ''; $html = ob_get_contents(); ob_end_clean(); echo $html; exit(); } function csv2array($file) { $row = 1; $result = array(); if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row != 1) { $result[] = array('partId' => $data[0], 'preProduction' => $data[1], 'number' => $data[2], 'name' => $data[3], 'clientId' => $data[4], 'weight' => $data[5], 'alloyTemper' => $data[6], 'status' => $data[7], 'image' => $data[8]); } $row++; } fclose($handle); } return $result; } $a = csv2array('02-details-part.csv'); $partVersionSql = $partVersionSqlInsert = 'INSERT INTO `cf_PartVersion` (`id`, `partId`, `preProduction`, `version`, `number`, `name`, `clientId`, `weight`, `alloyTemper`, `status`, `localDirectory`, `image`, `comments`, `userId`, `added`, `changed`) VALUES' . "\n"; $sorter = 0; $count = 1; foreach($a as $row) { $pos = strrpos($row['image'], '\\'); $image = substr($row['image'], $pos + 1); if ($row['image'] != '') { $image .= '.png'; } $partVersionSql .= '(NULL, ' . $row['partId'] . ', "' . $row['preProduction'] . '", 1, "' . str_replace('"', '\"', $row['number']) . '", "' . str_replace('"', '\"', $row['name']) . '", ' . $row['clientId'] . ', ' . ((float) $row['weight']) . ', "' . str_replace('"', '\"', $row['alloyTemper']) . '", "' . $row['status'] . '", "", "' . $image . '", "", ' . $sorter . ', NULL, NULL),' . "\n"; if ($count % 100 == 0) { $partVersionSql = substr($partVersionSql, 0, -2) . ";\n" . $partVersionSqlInsert; } $sorter++; $count++; } $partVersionSql = substr($partVersionSql, 0, -2) . ';'; $file = "importPartVersion.sql"; $handle = fopen($file, 'w'); fwrite($handle, $partVersionSql); fclose($handle); echo ('File "' . $file . '" has been created'); ?>