Reputation: 155
I have the following array for insert into database using Codeigniter's insert_batch.
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
)
)
It gives the following error while insert.
Error Number: 1054
Unknown column '0' in 'field list'
INSERT INTO `td_customer_lphone` (`0`, `1`) VALUES ('',''), ('+98','+78'), ('777','66'), ('77','66')
What am I doing wrong
Thanks for any help..
Upvotes: 0
Views: 252
Reputation: 6426
The (0, 1) in your statement is supposed to be a list of the field names that you are inserting into - you can't use ordinal field numbers as far as I am aware
something more like (replace field1 and field2 with the names ofg the columns from your table
INSERT INTO td_customer_lphone (field1, field2) VALUES ('',''), ('+98','+78'), ('777','66'), ('77','66')
Upvotes: 1