Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.0

Bug #2926 Where clause not being added in buildManipSQL
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)    

 [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 20:51 UTC] danielc
A query with a where clause of "WHERE 0"? That's very strange. A script making such a call could do a better job by skipping over the query execution entirely.
 [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.
 [2004-12-08 21:53 UTC] danielc
While WHERE 0 works on MySQL, I don't think it's valid per the SQL-99 standard. PostgreSQL rejects it, for example.