Class: DBI::BaseStatement
Direct Known Subclasses
Instance Method Summary collapse
- #[](attr) ⇒ Object
- #[]=(attr, value) ⇒ Object
- #bind_param(param, value, attribs) ⇒ Object
-
#bind_params(*bindvars) ⇒ Object
OPTIONAL ============================================.
- #cancel ⇒ Object
-
#column_info ⇒ Object
returns result-set column information as array of hashs, where each hash represents one column.
- #execute ⇒ Object
- #fetch ⇒ Object
- #fetch_all ⇒ Object
- #fetch_many(cnt) ⇒ Object
- #fetch_scroll(direction, offset) ⇒ Object
- #finish ⇒ Object
-
#initialize(attr = nil) ⇒ BaseStatement
constructor
A new instance of BaseStatement.
Constructor Details
#initialize(attr = nil) ⇒ BaseStatement
Returns a new instance of BaseStatement.
939 940 941 |
# File 'lib/dbi.rb', line 939 def initialize(attr=nil) @attr = attr || {} end |
Instance Method Details
#[](attr) ⇒ Object
1030 1031 1032 |
# File 'lib/dbi.rb', line 1030 def [](attr) @attr[attr] end |
#[]=(attr, value) ⇒ Object
1034 1035 1036 |
# File 'lib/dbi.rb', line 1034 def []=(attr, value) raise NotSupportedError end |
#bind_param(param, value, attribs) ⇒ Object
945 946 947 |
# File 'lib/dbi.rb', line 945 def bind_param(param, value, attribs) raise NotImplementedError end |
#bind_params(*bindvars) ⇒ Object
OPTIONAL
972 973 974 975 |
# File 'lib/dbi.rb', line 972 def bind_params(*bindvars) bindvars.each_with_index {|val,i| bind_param(i+1, val, nil) } self end |
#cancel ⇒ Object
977 978 |
# File 'lib/dbi.rb', line 977 def cancel end |
#column_info ⇒ Object
returns result-set column information as array of hashs, where each hash represents one column
964 965 966 |
# File 'lib/dbi.rb', line 964 def column_info raise NotImplementedError end |
#execute ⇒ Object
949 950 951 |
# File 'lib/dbi.rb', line 949 def execute raise NotImplementedError end |
#fetch_all ⇒ Object
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 |
# File 'lib/dbi.rb', line 1015 def fetch_all rows = [] loop do row = fetch break if row.nil? rows << row.dup end if rows.empty? nil else rows end end |
#fetch_many(cnt) ⇒ Object
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 |
# File 'lib/dbi.rb', line 1000 def fetch_many(cnt) rows = [] cnt.times do row = fetch break if row.nil? rows << row.dup end if rows.empty? nil else rows end end |
#fetch_scroll(direction, offset) ⇒ Object
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
# File 'lib/dbi.rb', line 980 def fetch_scroll(direction, offset) case direction when SQL_FETCH_NEXT return fetch when SQL_FETCH_LAST last_row = nil while (row=fetch) != nil last_row = row end return last_row when SQL_FETCH_RELATIVE raise NotSupportedError if offset <= 0 row = nil offset.times { row = fetch; break if row.nil? } return row else raise NotSupportedError end end |