Re: setFrom doesn't set keys
| From: | Alan Knowles | Date: | Thu, 05 Feb 2004 15:33:27 +0000 |
| Subject: | Re: setFrom doesn't set keys | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25518@lists.php.net to get a copy of this message | ||
Opps.. - that last answer was not quite correct... :)
setFrom NEVER sets keys - you have to do that manually. - to make sure you dont accidentally update the wrong data...
eg. posting a password update form with the table ID.. in the post request.....
insert will also ignore the value of a autoincrement/sequenced key, unless you define the sequenceKey method..
Regards
Alan
Joe Stump wrote:
I know this may be expected behavior if you fech() a row, update it with setFrom() and then do an update(), but what if your empty is brand new. Example: $do = & DB_DataObject::factory('table'); $do->setFrom($_POST); // yes this is bad, bear with me. if($do->insert()) { echo 'SUCCESS!'; } DBDO currently ignores keys completely in setFrom. I think a better behavior would be for DBDO to know that the key is empty and go ahead and populate the data (for inserts). Am I way off base here? --Joe -- Joe Stump, President JCS Solutions http://www.jcssolutions.com (734) 786 0176-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com