Database PDOException after INSERT
Closed this issue · 1 comments
Hi, constantly I'm receiving the error: PDOException: SQLSTATE[HY000]: General error
after execute an INSERT
using the db::query
method.
This is part of the code I'm using:
$params = array(
':purchaseId' => '123456789',
':sku' => '123456789',
':date' => '2015-11-19 00:00:00'
);
$query = "INSERT INTO links
SET purchase_id = :purchaseId,
item_id = (SELECT id
FROM items
WHERE sku = :sku),
date = :date
";
db::query($query, $params);
It does its job in the database perfectly. All is inserted in its tables, nevertheless it always throws the error
PDOException: SQLSTATE[HY000]: General error
. I sought in the class lib/database.php#L318 and I think that the issue could be related with the method fetchAll
as is mentioned in this message http://stackoverflow.com/a/12980031/1668897
Important: I've checked the methods: db::lastQuery()
, db::lastId()
are fine after the error, where lastId()
gives the last inserted id
. Also db::lastError()
returns a null
value.
What can I do? or Is there a different way to execute a query with a subquery without use the db::query()
method?
Sorry for the delay. Would it be possible to get a version of your app to test this? bastian@getkirby.com I'm not able to reproduce this here.