@Kevando - If you want the ID of something that happened 20 days ago,
you cant get the last insert ID. That only applies when you literally
just ran a query and need to get the ID.

If you want it from 20 days ago, do a find query and order by DESC
limit 1.

On Nov 4, 8:36 am, euromark <dereurom...@googlemail.com> wrote:
> you could use
> find->first() with order: id=>DESC
> this would get you the last insert id, no matter how many days passed
>
> although the above race conditions might result in problems (depending
> on the usage of this id)
>
> On 4 Nov., 16:28, AD7six <andydawso...@gmail.com> wrote:
>
> > On Nov 4, 3:50 pm, "Mike Karthauser" <mi...@brightstorm.co.uk> wrote:
>
> > > On Wed, November 3, 2010 7:05 pm, kevando wrote:
>
> > > > What about if my last insert/save was 20 days ago?
>
> > why don't you insert and then update if you want to do that. you can
> > easily wrap that in a transaction. anything else you do just risks a
> > race condition.
>
> > > > Basically -- I want to get the value of the current (or latest) id in 
> > > > the
> > > > beforeSave function
>
> > > $this->Model->getLastInsertId();
>
> > >http://book.cakephp.org/view/312/Models
>
> > > does what it says on the can.
>
> > which is "return null" unless you just inserted something.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to