Home » Database » DB_DataObject » Bug #1795
DataObject method update() not working correctly
Details
| Submitted | 2004-07-05 16:49 UTC |
|---|---|
| From | haziz at ut dot ee |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 4.3.6 |
| OS | Suse 9.1 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-05 16:49 UTC] haziz at ut dot ee
Description:
------------
The sql in update() is wrong when you want to update data like in your example in update().
Reproduce code:
---------------
$joinTableObj = DB_DataObject::factory("mod_intranet_group_join_user");
$joinTableObj->groupId = 1;
$joinTableObj->whereAdd("groupId = 5");
$joinTableObj->update();
Expected result:
----------------
UPDATE mod_intranet_group_join_user SET groupId = 1 WHERE groupId = 5
Actual result:
--------------
UPDATE mod_intranet_group_join_user SET groupId = 1 WHERE groupId = 5 AND mod_intranet_group_join_user.groupId = 1
[2004-11-30 12:47 UTC] laura at unique-media dot com
Even if it is not the primary key, it still causes problems!
I am trying to use an update clause similar to that documented here:
http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.update.php
...in example 26.3 - the syntax for an update query with a whereAdd(). However, either there is a fault with the documentation or a bug within the class, as it does not work in this manner. The variable I am trying to update is not a primary key (in fact it's not even an index).
$shw_req = new DataObjects_Shw_requirement;
$shw_req->status = 1;
$shw_req->whereAdd('show_id = 7');
$shw_req->whereAdd('requirement_id = 20');
$shw_req->update();
This code yields
dataobjects_shw_requirement: QUERY: UPDATE shw_requirement SET status = 1 WHERE show_id = 7 AND requirement_id = 20
And not
dataobjects_shw_requirement: QUERY: UPDATE shw_requirement SET status = 1 WHERE show_id = 7 AND requirement_id = 20 AND shw_requirement.status = 1
:(
[2004-11-30 12:49 UTC] laura at unique-media dot com
Whoops, on my previous comment it should read:
This code yields
dataobjects_shw_requirement: QUERY: UPDATE shw_requirement SET status =
1 WHERE show_id = 7 AND requirement_id = 20 AND shw_requirement.status =
1
And not
dataobjects_shw_requirement: QUERY: UPDATE shw_requirement SET status =
1 WHERE show_id = 7 AND requirement_id = 20