Re: Re: DB_DataObjects save method
| From: | Andrew S. Nagy | Date: | Fri, 29 Oct 2004 21:06:01 +0000 |
| Subject: | Re: Re: DB_DataObjects save method | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-34165@lists.php.net to get a copy of this message | ||
Justin Patrin wrote:
On Fri, 29 Oct 2004 16:45:24 -0400, Andrew S. Nagy <asnagy@webitecture.org> wrote:Although, this won't work. For many of my more "large scale" applications i don't use sequences, i set my own 32 bit id for the PK. Or, for example, if i had a database of books and i used the ISBN as the pk. So this method could only be used for DOs that use sequences or databases that support the replaceInto SQL statement. Ehh ... im starting to think this is a bad idea. AndrewAfter looking at how others do it, what about something like this: function replaceInto() {Don't you mean if (isset($this->$k)) ? This will only call $update if all keys are *not* set. Maybe you meant to reverse update() and insert() below? Yeah, the ! shouldn't be there.// This should call the replaceInto directly to the DB if it is // supported; otherwise use the following logic:// Determine if keys are set $update = 0; $keys = $this->keys(); foreach($keys as $k => $v) { if (!isset($this->$k)) {