After I do something like @text.save, how can I then get the insert id from the MySQL auto_increment field ? Thanks, -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/
On 7/14/05, Greg Donald <destiney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> After I do something like @text.save, how can I then get the insert id > from the MySQL auto_increment field ? >I think that the id is immediately available after a save. So if you do order.save then the id should be available after the save has successfully completed Try it... Shelby
On 7/14/05, Shelby Westman <shelby.westman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think that the id is immediately available after a save. So if you do > order.save > then the id should be available after the save has successfully completed > > Try it...@text.save returns true, I''m wanting the insert id from the query. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/
if @text.save @text.reload @text.id end On Jul 14, 2005, at 9:54 PM, Greg Donald wrote:> On 7/14/05, Shelby Westman <shelby.westman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I think that the id is immediately available after a save. So if >> you do >> order.save >> then the id should be available after the save has successfully >> completed >> >> Try it... >> > > @text.save returns true, I''m wanting the insert id from the query. > > > -- > Greg Donald > Zend Certified Engineer > MySQL Core Certification > http://destiney.com/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Greg Donald wrote:> On 7/14/05, Shelby Westman <shelby.westman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I think that the id is immediately available after a save. So if you do >> order.save >> then the id should be available after the save has successfully completed >> >> Try it... >> > > @text.save returns true, I''m wanting the insert id from the query. >After calling @text.save, @text.id should contain the new id.