Home » Database » DB_DataObject » Bug #1726
ORDER BY and LIMIT not considered on DELETE
Details
| Request #1726 | ORDER BY and LIMIT not considered on DELETE |
|---|---|
| Submitted | 2004-06-26 07:23 UTC |
| From | pear at l2gx dot net |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 4.3.6 |
| OS | All |
| Roadmaps | (Not assigned) |
Comments
[2004-06-26 07:23 UTC] pear at l2gx dot net
Description:
------------
When performing $do->delete(), LIMIT and ORDER BY
statements are not considered when performing the
DELETE. Using the normal DB_DO methology, it's
impossible to perform queries like:
DELETE FROM item_management_revisions WHERE
item_management_revisions.item_id = 31 AND
item_management_revisions.item_type = 1 ORDER BY
date_revision LIMIT 1
So you're forced to use raw queries: $do->query().
Reproduce code:
---------------
to enable this feature:
DB_DataObject.php line 1199:
remove:
$this->_query = array(); // as it's probably unset!
DB_DataObject.php line 1213:
change to:
$r = $this->_query("DELETE FROM {$table} {$this->_query['condition']} {$this->_query['order_by']} {$this->_query['limit']}");