Re: obtaining the next sequence id in a DataObject
| From: | Justin Patrin | Date: | Thu, 21 Apr 2005 18:30:41 +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-18885@lists.php.net to get a copy of this message | ||
On 4/21/05, Marek Kilimajer <lists@kilimajer.net> wrote:
> 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.
>
> *I* personaly need it with payment gateways, for example. I need the
> order id before it is inserted to the db, in case the payment fails.
This is what transactions are for. Start a transaction, insert the
order, do payment auth, if it fails rollback. Easy as that. Or you can
manually delete the order of the auth fails.
>
> >
> >
> >>
> >>On 21/04/2005, at 10:03 PM, Marek Kilimajer wrote:
> >>
> >>
> >>>Justin Patrin wrote:
> >>>
> >>>>On 4/20/05, Dan Rossi <pear@electroteque.org> wrote:
> >>>>
> >>>>>Hi there, I was wondering how its possible to get the next sequence
> >>>>>id
> >>>>>without having to get the connection and call the nextid from there.
> >>>>>is
> >>>>>there such a method ?
> >>>>>
> >>>>
> >>>>If you're talking about an autoinc field or a DB sequence, as long as
> >>>>the field / sequence is set up correctly it will be in the DO after
> >>>>you insert. Period.
> >>>
> >>>If it is a sequence, you can obtain it before actual insert query (and
> >>>then use it in the insert query)
> >>>
> >>>--
> >>>PEAR General Mailing List (http://pear.php.net/)
> >>>To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>
> >>
> >
> >
>
--
Justin Patrin