Re: obtaining the next sequence id in a DataObject
| From: | Justin Patrin | Date: | Thu, 21 Apr 2005 21:13:39 +0000 |
| Subject: | Re: obtaining the next sequence id in a DataObject | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18898@lists.php.net to get a copy of this message | ||
On 4/21/05, Dan Rossi <pear@electroteque.org> wrote:
>
> On 22/04/2005, at 3:26 AM, Justin Patrin wrote:
>
> > On 4/21/05, Dan Rossi <pear@electroteque.org> wrote:
> >> I was assuming insert called nextId too ? So wouldsnt it shoft it
> >> twice
> >> if called twice ?? :)
> >
> > Yes. *WHY* do you need it before the insert? Just $do->insert() and
> > access the field using $do->sequenceField.
> >
>
> Example in my insert method in the DO
>
> //get the connection here
>
> $this->fromValue('ticket_number','someprefix-00000'.$db->currID() +
> 1)
>
> I have however been told on the mysql list, this can cause problems ,
> as an entrry could have happens only seconds before this one did :|
> Therefore I may have to change my plan of attack and use CONCAT on the
> actual entry ? This would mean I wouldnt need sequences then. I however
> had another project which requires the issue number beforehand for
> creating directories from the issue number. This also is a big problem
> because i call nextID on a page way before the entry is inserted :| I
> think i should change my plan here and store the documents in a temp
> directory created with the user login ID and a timestamp. Therefore if
> the entry was never made or rollbacked i could clean it up and then
> move the files only once the record was made and collect the issue
> number then and create a directory.
>
Or...create the issue, *then* move the uploaded files. I don't see
what the problem here is...
You could also put them in a random (unique) directory and store the
directory name in the issue record.
--
Justin Patrin