我只想使用 Ruby 的 Sequel 获取 last_insert_id():
insertret = @con.run("INSERT INTO `wv_persons` ( `id` ) VALUES ( NULL )")
pp insertret.inspect # returns "nil", expected that..
last_insert_id = @con.run("SELECT LAST_INSERT_ID() AS last_id;")
pp last_insert_id.inspect # returns "nil", should be an ID
SELECT 查询应该返回 last_id 但 .run 不返回它。我应该改用什么方法?
解决方案:(感谢 Josh Lindsey)
last_insert_id = @con[:wv_persons].insert({})
last_insert_id = last_insert_id.to_s
puts "New person ["+ last_insert_id +"]"
最佳答案
关于Mysql/Ruby Sequel最后一次插入ID值,用什么方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3478024/