File: //usr/local/rvm/gems/ruby-3.0.2/doc/activerecord-6.1.4.1/ri/ActiveRecord/Result/cdesc-Result.ri
U:RDoc::NormalClass[iI"Result:ETI"ActiveRecord::Result;TI"Object;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I"<This class encapsulates a result returned from calling ;TI"O{#exec_query}[rdoc-ref:ConnectionAdapters::DatabaseStatements#exec_query] ;TI"5on any database connection adapter. For example:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[I"\result = ActiveRecord::Base.connection.exec_query('SELECT id, title, body FROM posts')
;TI"4result # => #<ActiveRecord::Result:0xdeadbeef>
;TI"
;TI"+# Get the column names of the result:
;TI"result.columns
;TI""# => ["id", "title", "body"]
;TI"
;TI",# Get the record values of the result:
;TI"result.rows
;TI"%# => [[1, "title_1", "body_1"],
;TI"% [2, "title_2", "body_2"],
;TI" ...
;TI" ]
;TI"
;TI"I# Get an array of hashes representing the result (column => value):
;TI"result.to_a
;TI"B# => [{"id" => 1, "title" => "title_1", "body" => "body_1"},
;TI"B {"id" => 2, "title" => "title_2", "body" => "body_2"},
;TI" ...
;TI" ]
;TI"
;TI"6# ActiveRecord::Result also includes Enumerable.
;TI"result.each do |row|
;TI"- puts row['title'] + " " + row['body']
;TI"end;T:@format0:
@fileI" lib/active_record/result.rb;T:0@omit_headings_from_table_of_contents_below0;
0;0[[
I"column_types;TI"R;T:publicFI" lib/active_record/result.rb;T[
I"columns;T@3;F@4[
I" rows;T@3;F@4[ [[I"Enumerable;To;;[ ;
@/;0@4[[I"
class;T[[;[[I"new;T@4[:protected[ [:private[ [I"
instance;T[[;[[I"[];T@4[I" each;T@4[I"empty?;T@4[I"includes_column?;T@4[I"initialize_copy;T@4[I" last;T@4[I"length;T@4[I" to_a;T@4[I"to_ary;T@4[;[ [;[[I"column_type;T@4[I"hash_rows;T@4[ [U:RDoc::Context::Section[i 0o;;[ ;
0;0[@/I"ActiveRecord;TcRDoc::NormalModule