$db->updateObject();
method,Boolean: true/false
object(PDOStatement)#340 (1) { ["queryString"]=> string(56) "UPDATE `am_lots` SET `hammer_price`='0' WHERE `id` = '0'" }
Database Type: MySQL (PDO)
Error reporting: Maximum
Debugging: false
Joomla Version: 3.8.6
We have literally installed the Joomla instance and started developing, it's been about 2 months, and then we noticed this issue. This doesn't happen when using MySQLi as the driver.
Priority | Urgent | ⇒ | Medium |
Hi @mbabker, thanks for that but that isn't the case, if we create a query that WILL fail, then it still returns the PDOStatement.
Therefore doing something like:
$status = $db->updateObject(): if ($status) {}
This will always succeed, even if it fails.
Then that means PDOStatement::execute()
is returning a true-ish value which our API does not consider a query failure (a query failure being an actual database error, not a "no results" type thing). If there's a case where it is returning something true-ish that should be evaluated as a false or error case, this check needs updated to account for it.
@mbabker then I would suggest that check needs to be looked at, because only if there is an error within the jDatabase class will it throw an error, otherwise it will execute a update query which fails, and it does not catch it or return anything.
Status | New | ⇒ | Discussion |
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Confirmed |
Build | master | ⇒ | staging |
Status | Confirmed | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-10-15 19:08:23 |
Closed_By | ⇒ | roland-d | |
Labels |
Added:
No Code Attached Yet
Removed: ? |
@dannysmc95 This was just brought to my attention, so I figured I give it a test on Joomla 4, and I see your expected behavior now. A successful query will return a boolean true, a failed query will throw an exception.
If you are not seeing this behavior on Joomla 4 please re-open the issue so we can investigate further.
Can't be fixed without a B/C break. Don't worry about the return value here, at this point if something is using the return of
JDatabaseDriver::execute()
that'll indicate a successful query and a failed query will have an exception thrown.