Menu ▾ ▴

#124 5dev37: dbi delete function broken

open
nobody
None
5
2005-02-11
2005-02-11
No

Any function using delete() will fail because the
output of the broken function is:
DELETE FROM group_products WHERE gid='13'WHERE pid='4';
but it SHOULD be:
DELETE FROM group_products WHERE gid='13' AND pid='4';
This is caused by not resetting a flag inside the
foreach loop. Replace/fix this function in file:
includes/classes/dbi.api_class.php
-------------------------------------------------------------
function delete($table,$matches)
{
$conditions = null;

if (empty($table) or count($matches) < 1) {
return;
}

$sql = "DELETE FROM {$table} ";

foreach ($matches as $field => $value) {
$sql .= is_null($conditions) ? "WHERE " : "AND ";
$sql .= "{$field}='{$value}' "; //fmg: added
space here
//fmg: reset $conditions so next time in loop
print "AND"
$conditions = TRUE;
}

$this->query($sql);
}
-------------------------------------------------------------

Cheers,
Fil

Discussion


Log in to post a comment.