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?
Hi, constantly I'm receiving the error:
PDOException: SQLSTATE[HY000]: General error
after execute anINSERT
using thedb::query
method.This is part of the code I'm using:
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 methodfetchAll
as is mentioned in this message http://stackoverflow.com/a/12980031/1668897Important: I've checked the methods:
db::lastQuery()
,db::lastId()
are fine after the error, wherelastId()
gives the last insertedid
. Alsodb::lastError()
returns anull
value.What can I do? or Is there a different way to execute a query with a subquery without use the
db::query()
method?