mysql - 到底是json還是數組,求PHP批量插入資料庫辦法

來源:互聯網
上載者:User

到底是json還是數組
print_r (json_decode($json2));echo "

"; 
print_r (json_decode($json2, true));echo "
";

print_r (json_ecode($json2, true));echo "

";

都不管用直接用echo輸出

$pageContents = $client->getContent();//getError
$pageContents =str_replace('trde_fullo_get_rsponse','',$pageContents);
$pageContents =str_replace('"jdp_rese":"{"":{"tde":{','',$pageContents);

echo $pageContents;

tid":2356471828086946,"buyer_nick":"圖圖愛跳舞","created":"2016-09-16 11:24:05","payment":"657.97","pay_time":"2016-09-16 11:24:22","modified":"2016-10-08 21:03:55","num":1,"price":"1985.00","receiver_name":"小百度","receiver_address":" 十裡鋪先行大廈(務必聯絡周冰簽收!)","status":"TRADE_FINISHED","total_fee":"2054.97","num":1,"oid":2356471828086946,"outer_iid":"gncfastact240x2","payment":"657.97","status":"TRADE_FINISHED","title":"GN美國原裝口香糖","price":"1985.00"

求指點批量插入mysql語句,最好來了例子,多謝大神了,新手上路。

回複內容:

到底是json還是數組
print_r (json_decode($json2));echo "

"; 
print_r (json_decode($json2, true));echo "
";

print_r (json_ecode($json2, true));echo "

";

都不管用直接用echo輸出

$pageContents = $client->getContent();//getError
$pageContents =str_replace('trde_fullo_get_rsponse','',$pageContents);
$pageContents =str_replace('"jdp_rese":"{"":{"tde":{','',$pageContents);

echo $pageContents;

tid":2356471828086946,"buyer_nick":"圖圖愛跳舞","created":"2016-09-16 11:24:05","payment":"657.97","pay_time":"2016-09-16 11:24:22","modified":"2016-10-08 21:03:55","num":1,"price":"1985.00","receiver_name":"小百度","receiver_address":" 十裡鋪先行大廈(務必聯絡周冰簽收!)","status":"TRADE_FINISHED","total_fee":"2054.97","num":1,"oid":2356471828086946,"outer_iid":"gncfastact240x2","payment":"657.97","status":"TRADE_FINISHED","title":"GN美國原裝口香糖","price":"1985.00"

求指點批量插入mysql語句,最好來了例子,多謝大神了,新手上路。

這個明顯是json了

// TP3.2大量新增資料$dataList[] = array('name'=>'thinkphp','email'=>'thinkphp@gamil.com');$dataList[] = array('name'=>'onethink','email'=>'onethink@gamil.com');$User->addAll($dataList);

想知道是json還是數組,用var_dump列印下不就知道了
另外這個是從前端那邊傳過來的吧,目測傳的時候將json字串化了,你要在PHP上面轉數組的話還需要對字串進行解碼

json.decode("string...")

至於批量插入sql語句,給你一個簡單的提示,剩下靠自己把

 INSERT INTO table (q,w,e) VALUES (1,2,3), (2,3,4), (3,4,5), (3,4,9);
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.