I have such query

 INSERT IGNORE INTO 2_1_accountsforpaidused (DebtorDebtAndPayment) VALUES (?,?);

And such values

Array
(
[0] => 111
[1] => 222
)

Want in column DebtorDebtAndPayment insert VALUES (111,222). In one line 111, in the next line 222

But get such error

Error stmt_for_insert_accountsforpaidused!: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1

Tried to change query to INSERT IGNORE INTO 2_1_accountsforpaidused (DebtorDebtAndPayment) VALUES ((?),(?)); the same result

What is wrong?

有帮助吗?

解决方案

You're telling mysql you want to insert into one column and then you're providing it with two values. You either need to:

  1. Add the second column your are inserting into to your query

  2. Remove one of the values

  3. Alter the query so it is doing two inserts of one value

Number 3 looks like what you want:

INSERT IGNORE INTO 2_1_accountsforpaidused (DebtorDebtAndPayment) VALUES (?),(?);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top