Ruby의 MySql : Result 객체의 마지막 2 행을 살펴보고 싶습니다.루비 - MySQL의 결과 행 2 개 비교 : 결과 객체
2 개의 가장 최근 행에있는 매개 변수 중 하나가 동일하지 않도록해야합니다.
time= @con.query('select victim, t, TIMESTAMPDIFF(minute, t, now()) as timediff from iCu where userid = "'+user+'" and victim = "'+victim+'" order by t desc limit 2')
이것은 내 sql 쿼리입니다. 희생자가이 두 줄에서 동일하지 않은 것을 확인하기 위해 얻을 수있는 2 가지 값을 어떻게 비교할 수 있습니까? MySQL 명령이나 호출 후 루비 코드에서.
도움을 주시면 감사하겠습니다. 감사합니다
편집 : 더 많은 정보
저는 mysql gem을 사용하고 있습니다. 당신이 할 수 있도록,
이results.each do |row|
# conveniently, row is a hash
# the keys are the fields, as you'd expect
# the values are pre-built ruby primitives mapped from their corresponding field types in MySQL
puts row["id"] # row["id"].class == Fixnum
if row["dne"] # non-existant hash entry is nil
puts row["dne"]
end
end
추가 정보 here는 MySQL의 :: 결과를 처리하기위한