Re: Re: DB_DataObjects save method

From: Date: Fri, 29 Oct 2004 21:19:19 +0000
Subject: Re: Re: DB_DataObjects save method
References: 1 2 3 4 5 6 7  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-34170@lists.php.net to get a copy of this message
On Fri, 29 Oct 2004 17:06:01 -0400, Andrew S. Nagy <asnagy@webitecture.org> wrote: > Justin Patrin wrote: > > >On Fri, 29 Oct 2004 16:45:24 -0400, Andrew S. Nagy > ><asnagy@webitecture.org> wrote: > > > > > >>After looking at how others do it, what about something like this: > >> > >> function replaceInto() > >> { > >> // 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)) { > >> > >> > > > >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. > > 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. > No, this should still work. You just have to set up the PK manually in the ini file. Or, just set it up as a key in the DB and DO will automatically see that it's a key, even if you use a manual sequence of some kind to do it. -- paperCrane --Justin Patrin--

« previous php.pear.dev (#34170) next »