PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #2926

Where clause not being added in buildManipSQL

Details

Submitted2004-12-08 20:10 UTC
Fromjrust at php dot net
Assigneddanielc
StatusWont fix
PackageDB
PHP VersionIrrelevant
OSIrrelevant
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.