Rubyの続編を使用して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はそれを返しません。代わりにどの方法を使用すればよいですか?
解決策: (JoshLindseyに感謝します)
last_insert_id = @con[:wv_persons].insert({})
last_insert_id = last_insert_id.to_s
puts "New person ["+ last_insert_id +"]"