I'm using the MySQL2 Ruby driver - but it seems a bit redundant having to call
result.each{ |r| puts r['name'] }
for a single row of data that is returned. There must be a simpler way to get the mysql field I want without having to use the each block?
Your result should be a Mysql2::Result and that's Enumerable so you can use first (and the rest of the Enumerable goodies) on it:
puts result.first['name']
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With