Home » Database » DB » Bug #2926
Where clause not being added in buildManipSQL
Details
| Submitted | 2004-12-08 20:10 UTC |
|---|---|
| From | jrust at php dot net |
| Assigned | danielc |
| Status | Wont fix |
| Package | DB |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2004-12-08 20:10 UTC] jrust at php dot net
Description:
------------
It is entirely possible that an autogenerated where statement would be just 0, in which case the UPDATE statement should not affect any rows. However, in the current code, such a where statement causes all rows to be affected!
Reproduce code:
---------------
$query = $db->buildManipSQL('table', array('id'), DB_AUTOQUERY_UPDATE, 0);
echo $query;
UPDATE table SET id = ?;
To fix:
Change line 907 to:
if ($where !== false) {
Expected result:
----------------
UPDATE table SET id = ? WHERE 0;
[2004-12-08 21:45 UTC] jrust at php dot net
True, it is not the best SQL. However, if a developer wants the WHERE clause to be 0 the method should not prevent them from doing so. The fact is that they are passing 0, not false as the value for $where and the variable is not being evaluated correctly.