Working on a custom extension for our site and noticed that there does not appear to be any method of checking for MySQL INSERT errors. If the insert query produces an error, it just stops. Is there any way to utilize $this->db->query in such a way that rather than choking, an error message is produced allowing the insert query to be ignored and error message returned for debugging purposes?
Be sure you have error logging enabled. By default you should get an error that explains the issue
Example:
http://forum.opencart.com/viewtopic.php?t=50292#p238419
Example:
http://forum.opencart.com/viewtopic.php?t=50292#p238419
Thanks Q. We have the log available for review after the fact but wondering if there is an error checking system (existing or add-on?) that would allow the error to be bypassed, for example:
if ( $query->error = "ABC"), $this->emailAdmin("Error Detail"), perform alternate action... else, proceed as planned, etc, etc;
Is this something that OpenCart is capable of doing?
if ( $query->error = "ABC"), $this->emailAdmin("Error Detail"), perform alternate action... else, proceed as planned, etc, etc;
Is this something that OpenCart is capable of doing?
UPDATE & SELECT queries offer this feature as $query->error but INSERT queries do not. The whole function just chokes when an INSERT query fails, but when an UPDATE or SELECT query fails the error is produced as an object.
Why not with the INSERT queries?
Why not with the INSERT queries?
Not sure where you're getting your info from but it's not accurate for a default install. The only values that are returned for db::query are bool true (e.g. INSERT, UPDATE) or an object with properties row, rows, and num_rows (e.g. SELECT).furrywombat wrote:UPDATE & SELECT queries offer this feature as $query->error but INSERT queries do not. The whole function just chokes when an INSERT query fails, but when an UPDATE or SELECT query fails the error is produced as an object.
-Ryan
You're right... I was thinking of something else for the ->error object, however, what would cause an INSERT/UPDATE error to choke a function rather than simply returning true/false?
Who is online
Users browsing this forum: Bing [Bot] and 22 guests