Re: DB_DataObjects - Update issues
| From: | Justin Patrin | Date: | Sun, 13 Aug 2006 02:22:13 +0000 |
| Subject: | Re: DB_DataObjects - Update issues | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24906@lists.php.net to get a copy of this message | ||
On 8/12/06, Ian Warner <iwarner@triangle-solutions.com> wrote:
Justin Patrin wrote: On 8/12/06, Ian Warner <iwarner@triangle-solutions.com> wrote:No. No, you didn't.Read the error message again. $sql1->update(DB_DATAOBJECT_WHEREADD_ONLY); Yes I tried thisHi Just ran into a strange issue with Update that I have never encountered before, google yields no rewards. Code to execute: DB_DataObject::debugLevel(5);$sql1 = DB_DataObject::factory(TBL_SMS_CENTER_PENDING); $sql1->status = 'Suspended'; $sql1->whereAdd("DB_DataObject::debugLevel(0); Error info is: DO_Sms_pending: CONNECT: Checking for database database_ in options DO_Sms_pending: CONNECT: USING CACHED CONNECTION DO_Sms_pending: ERROR: update: trying to perform an update without the key set, and argument to update is not DB_DATAOBJECT_WHEREADD_ONLYpending_id= '" . $sql->pending_id . "'"); $sql1->update(); print_r($sql1);
DB_DataObject::debugLevel(1);
$sql1 = DB_DataObject::factory(TBL_SMS_CENTER_PENDING);
// $sql1->status = 'Suspended';
$sql1->whereAdd("pending_id = '" . $sql->pending_id . "'");
$sql1->update();
Once again you ignored the error.
Do this!
$sql1->update(DB_DATAOBJECT_WHEREADD_ONLY);
Yes, doing it in a loop also works.print_r($sql1); DB_DataObject::debugLevel(0);and still get the same error: |*DO_Sms_pending: ERROR:* update: trying to perform an update without the key set, and argument to update is not DB_DATAOBJECT_WHEREADD_ONLY |So what does "without the key set mean" as explained the pending ID is the primary key. I should be able to update a column also right with the set command? so $sql1->status = 'Suspended'; should be fine? Ok then I tried this with the rest of the code I have this seemed the best solution, the update happens in a loop so this is required i think.// Update the row to make it suspended. Dont update if debug is on. $original = clone($sql); $sql->status = 'Suspended'; ($debug) ? '' : $sql->update($original);And it worked.
Thanks for the help.-- Justin PatrinDO_Sms_pending Object ( [__table] => sms_pending [pending_id] => [data] => [priority] => [creation_date] => [revision_date] => [status] => Suspended [id] => [_DB_DataObject_version] => 1.8.4 [N] => 0 [_database_dsn] => [_database_dsn_md5] => c9f3ecac1f2cadc9e5c4095e36c2ad6b [_database] => admin [_query] => Array ( [condition] => WHERE (pending_id= '1' ) [group_by] => [order_by] => [having] => [limit_start] => [limit_count] => [data_select] => * ) [_DB_resultid] => [_resultFields] => [_link_loaded] => [_join] => [_lastError] => ) Array ( [condition] => WHERE (pending_id= '1' ) [group_by] => [order_by] => [having] => [limit_start] => [limit_count] => [data_select] => * ) The schema is set as: which is correct, pending_id is a primary key also. [sms_pending] pending_id = 129 data = 194 priority = 130 creation_date = 129 revision_date = 129 status = 130 [sms_pending__keys] pending_id = N Any help appreciated Cheers Ian -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php