preg_replace(): Parameter mismatch, pattern is a string while replacement is an array
위에 에러메시지를 보면 helper의 671라인? 어찌됐든 replace 함수를 가르키며
패턴은 문자열인데 리플레이스먼트는 배열이라는 알수없는 소리를 한다.
어쨋든 어떤상황이냐면
Add products에서 밑의 + 버튼을 누르면 제품이 계속 추가되는 상황이고 해당 input에는
product_name[]이라는 배열을 추가 추가 추가 하는 그런 매우 흔한 (?) 화면이다
추가된 값을 mysql안에 넣어야되는데 그럼 컨트롤러 내부에서 implode(",", array) 이런식으로
문자열화해서 넣을 예정이었다. 그런데 위의 에러가 나온거
뭔가 라라벨 프레임워크 내부적으로 나의 뻘짓을 감지하고 뻘짓하지 말라고 에러를 뿌리나보다 하고 관련 글들(대부분 영어)을 거진 2시간 가까이 읽고 읽고 뭐가 문제지 하면서 안굴러가는 머리 굴려보아도 당췌 알수없는것들뿐
알고보니 컨트롤러 내부에서 product_name을 두번 이나 저장하고 있었다.
$order->product_name = implode(",", array)
.....
$order->product_name = get::input('product_name');
이런식으로 앞으로는 문제가 발생하면 원인부터 자세하게 살피고 뻘짓을 해야겠다.
내 두시간 어쩔거냐!
2015년 10월 14일 수요일
2015년 10월 13일 화요일
동적인 테이블 tr 추가하기
좋은 소스가 있어서 참고용으로 저장합니다
출처 : http://stove99.tistory.com/93
출처 : http://stove99.tistory.com/93
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ // 옵션추가 버튼 클릭시 $("#addItemBtn").click(function(){ // item 의 최대번호 구하기 var lastItemNo = $("#example tr:last").attr("class").replace("item", ""); var newitem = $("#example tr:eq(1)").clone(); newitem.removeClass(); newitem.find("td:eq(0)").attr("rowspan", "1"); newitem.addClass("item"+(parseInt(lastItemNo)+1)); $("#example").append(newitem); }); // 항목추가 버튼 클릭시 $(".addBtn").live("click", function(){ var clickedRow = $(this).parent().parent(); var cls = clickedRow.attr("class"); // tr 복사해서 마지막에 추가 var newrow = clickedRow.clone(); newrow.find("td:eq(0)").remove(); newrow.insertAfter($("#example ."+cls+":last")); // rowspan 조정 resizeRowspan(cls); }); // 삭제버튼 클릭시 $(".delBtn").live("click", function(){ var clickedRow = $(this).parent().parent(); var cls = clickedRow.attr("class"); // 각 항목의 첫번째 row를 삭제한 경우 다음 row에 td 하나를 추가해 준다. if( clickedRow.find("td:eq(0)").attr("rowspan") ){ if( clickedRow.next().hasClass(cls) ){ clickedRow.next().prepend(clickedRow.find("td:eq(0)")); } } clickedRow.remove(); // rowspan 조정 resizeRowspan(cls); }); // cls : rowspan 을 조정할 class ex) item1, item2, ... function resizeRowspan(cls){ var rowspan = $("."+cls).length; $("."+cls+":first td:eq(0)").attr("rowspan", rowspan); } }); </script></head><body><button id="addItemBtn">옵션추가</button><table id="example" border="1px"> <tr> <th>옵션명</th> <th>항목명</th> <th>필수항목</th> <th>가격</th> <th>재고</th> <th>옵션추가</th> </tr> <tr class="item1"> <td><input type="text" /><button class="addBtn">항목추가</button></td> <td><input type="text" /></td> <td><input type="checkbox" /></td> <td><input type="text" /></td> <td><input type="text" /></td> <td><button class="delBtn">삭제</button></td> </tr> <tr class="item2"> <td><input type="text" /><button class="addBtn">항목추가</button></td> <td><input type="text" /></td> <td><input type="checkbox" /></td> <td><input type="text" /></td> <td><input type="text" /></td> <td><button class="delBtn">삭제</button></td> </tr> <tr class="item3"> <td><input type="text" /><button class="addBtn">항목추가</button></td> <td><input type="text" /></td> <td><input type="checkbox" /></td> <td><input type="text" /></td> <td><input type="text" /></td> <td><button class="delBtn">삭제</button></td> </tr> <tr class="item4"> <td><input type="text" /><button class="addBtn">항목추가</button></td> <td><input type="text" /></td> <td><input type="checkbox" /></td> <td><input type="text" /></td> <td><input type="text" /></td> <td><button class="delBtn">삭제</button></td> </tr></table></body></html>
피드 구독하기:
글 (Atom)
-
운영체제를 다시 설치할때 보통 윈도우 인스톨러인가 UUI ? 뭐 정확히는몰라도 여러가지 프로그램을 사용하는데 이번에 rufus 라는 프로그램을 접하게 되었다. rufus 오류 미디어를 열 수 없습니다. 이런 오류를 뿜으면서 자꾸 안된다. ...
-
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) Posted on 22/04/2015 by Admin | Leave ...
-
국비지원 프론트엔드 과정을 선택한건 정말 잘못된 선택이었다. 해당과정에서 배운건 html , javascript, css, php 프로젝트들... 추가적으로 angularjs , spa 이런 문구들이 들어있는데 말그대로 맛보기였다. 제대...
