, 로 변환함 $colarr1[$i] = pipetocomma($colarr1[$i]); $colarr2[$i] = pipetocomma($colarr2[$i]); $colarr3[$i] = pipetocomma($colarr3[$i]); $colarr4[$i] = pipetocomma($colarr4[$i]); $colarr5[$i] = pipetocomma($colarr5[$i]); $colarr6[$i] = pipetocomma($colarr6[$i]); $colarr7[$i] = pipetocomma($colarr7[$i]); $colarr8[$i] = pipetocomma($colarr8[$i]); $colarr9[$i] = pipetocomma($colarr9[$i]); $colarr10[$i] = pipetocomma($colarr10[$i]); $colarr11[$i] = pipetocomma($colarr11[$i]); $colarr12[$i] = pipetocomma($colarr12[$i]); $colarr13[$i] = pipetocomma($colarr13[$i]); try { $pdo->beginTransaction(); // Collect input data $vendor_code = $colarr1[$i]; $vendor_name = $colarr2[$i]; $address = $colarr3[$i]; $representative_name = $colarr4[$i]; $phone = $colarr5[$i]; $mobile = $colarr6[$i]; $note = $colarr7[$i]; $fax = $colarr8[$i]; $email = $colarr9[$i]; $business_type = $colarr10[$i]; $item_type = $colarr11[$i]; $manager_name = $colarr12[$i]; $contact_info = $colarr13[$i]; $represent = '대표코드'; // 대표코드로 지정 $searchtag = $vendor_code . ' ' . $vendor_name . ' ' . $address . ' ' . $representative_name . ' ' . $phone . ' ' . $mobile . ' ' . $note . ' ' . $fax . ' ' . $email . ' ' . $business_type . ' ' . $item_type . ' ' . $manager_name . ' ' . $contact_info; // Prepare SQL insert statement $sql = "INSERT INTO " . $DB . "." . $tablename . " ("; $sql .= "vendor_code, vendor_name, representative_name, address, "; $sql .= "business_type, item_type, phone, mobile, email, "; $sql .= "fax, manager_name, contact_info, note, searchtag, represent"; $sql .= ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmh = $pdo->prepare($sql); // Bind the values to the prepared statement $stmh->bindValue(1, $vendor_code, PDO::PARAM_STR); $stmh->bindValue(2, $vendor_name, PDO::PARAM_STR); $stmh->bindValue(3, $representative_name, PDO::PARAM_STR); $stmh->bindValue(4, $address, PDO::PARAM_STR); $stmh->bindValue(5, $business_type, PDO::PARAM_STR); $stmh->bindValue(6, $item_type, PDO::PARAM_STR); $stmh->bindValue(7, $phone, PDO::PARAM_STR); $stmh->bindValue(8, $mobile, PDO::PARAM_STR); $stmh->bindValue(9, $email, PDO::PARAM_STR); $stmh->bindValue(10, $fax, PDO::PARAM_STR); $stmh->bindValue(11, $manager_name, PDO::PARAM_STR); $stmh->bindValue(12, $contact_info, PDO::PARAM_STR); $stmh->bindValue(13, $note, PDO::PARAM_STR); $stmh->bindValue(14, $searchtag, PDO::PARAM_STR); $stmh->bindValue(15, $represent, PDO::PARAM_STR); // Execute the statement $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: " . $Exception->getMessage(); } // 신규입력된 num 추출 $sql = "select * from " . $DB . "." . $tablename . " order by num desc "; try{ $stmh = $pdo->query($sql); // 검색조건에 맞는글 stmh $temp = $stmh->rowCount(); $row = $stmh->fetch(PDO::FETCH_ASSOC); $num=$row["num"]; } catch (PDOException $Exception) { print "오류: ".$Exception->getMessage(); } if(empty($secondordnum)) { // 대표아이디 설정하기 새로 생성된 코드가 secondordnum이 된다. try { $pdo->beginTransaction(); $sql = " UPDATE " . $DB . "." . $tablename . " SET "; $sql .= " secondordnum=? " ; $sql .= " WHERE num = ? LIMIT 1"; $stmh = $pdo->prepare($sql); $stmh->bindValue(1, $num , PDO::PARAM_STR); $stmh->bindValue(2, $num, PDO::PARAM_STR); $stmh->execute(); $pdo->commit(); } catch (PDOException $Exception) { $pdo->rollBack(); print "오류: " . $Exception->getMessage(); } } } } //각각의 정보를 하나의 배열 변수에 넣어준다. $data = array( "colarr1" => $colarr1 ); //json 출력 echo(json_encode($data, JSON_UNESCAPED_UNICODE)); ?>