1

I got this request:

"START TRANSACTION; DELETE FROM `awaiting_auth` WHERE `code` = '06b8465eed00727a1eac49fae89b88f876ded2eb' LIMIT 1; INSERT IGNORE INTO `prsn` SET `login` = 'new_user', `passwd` = '40bd001563085fc35165329ea1ff5c5ecbdbbeef', `color` = '#cbc5f2'; COMMIT;"

And I receive this error:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELETE FROM awaiting_auth WHERE code = '06b8465eed00727a1eac49fae89b88f876de' at line 1".

However when executing sql via terminal everything goes well and no errors are thrown.
What is wrong with my request? Thanks in advance.

4

4 回答 4

2

您必须将查询拆分为单独的 ->query() 调用。SQL 控制台会自动执行此操作。例如

->query("START TRANSACTION");
->query("DELETE FROM...");
于 2013-08-12T11:10:01.570 回答
0

每个查询一个操作。因此,您需要将查询拆分为单个查询。

于 2013-08-12T11:09:40.923 回答
0

只需一个一个地运行这些查询,而不是在单个数据包中。

于 2013-08-12T11:09:52.380 回答
0

尝试单独执行每个语句:

START TRANSACTION;
DELETE FROM `awaiting_auth` WHERE `code` = '06b8465eed00727a1eac49fae89b88f876ded2eb' LIMIT 1;
INSERT IGNORE INTO `prsn`(`login`, `passwd`, `color`) VALUES('new_user','40bd001563085fc35165329ea1ff5c5ecbdbbeef', '#cbc5f2');
COMMIT;
于 2013-08-12T11:11:10.293 回答