2013-06-21 20 views
0

我有以下數組用於使用Codeigniter的insert_batch插入數據庫。Insert_batch錯誤 - mysql

Array 
(
[td_customer_lphone] => Array 
    (
     [0] => Array 
      (
       [cust_lphone_id] => 
       [l_ph_cc] => +98 
       [l_ph_ac] => 777 
       [l_ph_no] => 77 
      ) 

     [1] => Array 
      (
       [cust_lphone_id] => 
       [l_ph_cc] => +78 
       [l_ph_ac] => 66 
       [l_ph_no] => 66 
      ) 

    ) 

它在插入時給出以下錯誤。

Error Number: 1054 

Unknown column '0' in 'field list' 

INSERT INTO `td_customer_lphone` (`0`, `1`) VALUES ('',''), ('+98','+78'), ('777','66'), ('77','66') 

我在做什麼錯

感謝您的幫助..

+0

關聯數組的關鍵字是'0',它實際上被翻譯成列名到表中,這是錯誤的原因 – karthikr

+0

'$ this-> db-> insert_batch('mytablename',$ data ['td_customer_lphone']] );' – tomexsans

回答

1

(0,1)在你的語句應該是要插入的字段名的列表 - 你不能用序場數的據我所知

更多的東西一樣(從表中字段1替換和Field2與OFG列名

INSERT INTO td_customer_lphone (field1, field2) VALUES ('',''), ('+98','+78'), ('777','66'), ('77','66')