'; $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'); $partSql = $partSqlInsert = 'INSERT INTO `cf_Part` (`id`, `blockedVersion`, `blockedBy`, `blockedAt`, `height`, `defaultProcessId`, `currentVersion`, `sorter`, `added`, `changed`) VALUES' . "\n"; $sorter = 0; $count = 1; foreach($a as $row) { $partSql .= '(' . $row['partId'] . ', 0, 0, NULL, 300, 0, ' . $count . ', ' . $sorter++ . ', NULL, NULL),' . "\n"; if ($count % 100 == 0) { $partSql = substr($partSql, 0, -2) . ";\n" . $partSqlInsert; } $count++; } $partSql = substr($partSql, 0, -2) . ';'; $file = "importPart.sql"; $handle = fopen($file, 'w'); fwrite($handle, $partSql); fclose($handle); echo ('File "' . $file . '" has been created'); ?>