Welcome Guest, Not a member yet? Register   Sign In
Getting auto_increment value
#1

[eluser]bikuta[/eluser]
Hi guys,

I have a table which has an 'id' field which is auto_increment. Is it possible for me to use Active Record and have it return the 'id' value (after doing an INSERT) or is there another way to get that value without having to do a SELECT query.

The reason I need this is so that I can insert the id into the related tables.

E.g.,
Composer (id, name)
Song (id, title, composerid)

Once I insert a new composer I need the 'id' to be inserted as the 'composerid' in the corresponding Song record.

Just trying to find the best way to do this, because I know MySQL does have a method to retrieve the unique value, i.e., mysql_insert_id(). It would be good if I can do it through Active Record.


Messages In This Thread
Getting auto_increment value - by El Forum - 07-08-2007, 05:43 PM
Getting auto_increment value - by El Forum - 07-08-2007, 05:46 PM
Getting auto_increment value - by El Forum - 07-08-2007, 05:53 PM
Getting auto_increment value - by El Forum - 07-08-2007, 07:01 PM
Getting auto_increment value - by El Forum - 07-08-2007, 07:30 PM
Getting auto_increment value - by El Forum - 02-11-2011, 05:28 PM
Getting auto_increment value - by El Forum - 02-11-2011, 07:27 PM
Getting auto_increment value - by El Forum - 02-11-2011, 07:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB