236 | | while (!feof($fp)) { |
237 | | $arrCSV = fgetcsv($fp, ZIP_CSV_LINE_MAX); |
238 | | if (empty($arrCSV)) continue; |
239 | | $cntCurrentLine++; |
240 | | if ($cntCurrentLine >= $start) { |
241 | | $sqlval = array(); |
242 | | $sqlval['zip_id'] = $cntCurrentLine; |
243 | | $sqlval['zipcode'] = $arrCSV[2]; |
244 | | $sqlval['state'] = $arrCSV[6]; |
245 | | $sqlval['city'] = $arrCSV[7]; |
246 | | $sqlval['town'] = $arrCSV[8]; |
247 | | $objQuery->insert('mtb_zip', $sqlval); |
| 236 | $begin = microtime(true); |
| 237 | |
| 238 | if ($fp !== false) { |
| 239 | $line = file(ZIP_CSV_UTF8_REALFILE); |
| 240 | // $dbconn = pg_connect("host=127.0.0.1 dbname=eccube_213 user=kentaro_ohkouchi password=foo"); |
| 241 | // pg_query($dbconn, 'BEGIN'); |
| 242 | // $result = pg_prepare($dbconn, 'zip_insert', 'INSERT INTO mtb_zip (zip_id, zipcode, state, city, town) VALUES ($1, $2, $3, $4, $5)'); |
| 243 | $objQuery->begin(); |
| 244 | $sth = $objQuery->prepare('INSERT INTO mtb_zip (zip_id, zipcode, state, city, town) VALUES (?, ?, ?, ?, ?)', null, MDB2_PREPARE_MANIP); |
| 245 | |
| 246 | for($i = 0; $line[$i] != ''; $i ++){ |
| 247 | $array = explode(",", $line[$i]); |
| 248 | // pg_send_execute($dbconn, 'zip_insert', array($i, $array[2], $array[6], $array[7], $array[8])); |
| 249 | $objQuery->execute($sth, array($i, $array[2], $array[6], $array[7], $array[8])); |
| 250 | |
| 251 | if ($i % $disp_line == 0 && $img_cnt < IMAGE_MAX) { |
| 252 | echo '<img src="' . $img_path . 'graph_1_w.gif">'; |
| 253 | SC_Utils_Ex::sfFlush(); |
| 254 | $img_cnt++; |
| 255 | } |
| 256 | SC_Utils_Ex::extendTimeOut(); |