|
||||||||||
|
||||||||||
May 22, 2008 I see this come up on the Rails list from time to time, so I figured I'd document it here as a blog entry. To get the next auto_increment id from a MySQL table using ActiveRecord: @next = ActiveRecord::Base.connection.execute( " SELECT auto_increment FROM information_schema.tables WHERE table_name='foo' " ).fetch_hash['auto_increment'].to_i
|
|
|||||||||
|
||||||||||
Also...
By: Gabe <gabe at websaviour dot com>
Posted: 1 year ago
If you have more than one database with that table you will need to specify the database name as a table_schema='bar' clause.