Hi, all. Right now, when I want to pull a hash out of a database, I
find myself first pulling all matching rows from my select, then
iterating through all the hashes in a given row. Surely, when I've got
a row, I should be able to say something akin to
puts row["foo"]
and have it spit out its value, "bar", instead of doing what I am right
now, which is
row.each_pair do |key, value|
stuff happens here
end
Pointers? (And apologies if this is a totally newb kind of
question...)
Thanks!
-Ken
on 2013-01-15 22:49
on 2013-01-16 10:00
Ken D'Ambrosio wrote in post #1092440: > Hi, all. Right now, when I want to pull a hash out of a database, > You don't pull hashes out of databases. You select rows. > I > find myself first pulling all matching rows from my select, then > iterating through all the hashes in a given row. > Rows do not have 'hashes'; they have columns. > Surely, when I've got > a row, I should be able to say something akin to > puts row["foo"] > and have it spit out its value, "bar", instead of doing what I am right > now, which is > > row.each_pair do |key, value| > stuff happens here > end > > Pointers? (And apologies if this is a totally newb kind of > question...) > > Thanks! > > -Ken results.each do |row| puts row['column_name'] end
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.