method
exec_query
v3.1.0 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::SQLiteAdapter
exec_query(sql, name = nil, binds = [])public
DATABASE STATEMENTS ======================================
# File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 170
def exec_query(sql, name = nil, binds = [])
log(sql, name, binds) do
# Don't cache statements without bind values
if binds.empty?
stmt = @connection.prepare(sql)
cols = stmt.columns
records = stmt.to_a
stmt.close
stmt = records
else
cache = @statements[sql] ||= {
:stmt => @connection.prepare(sql)
}
stmt = cache[:stmt]
cols = cache[:cols] ||= stmt.columns
stmt.reset!
stmt.bind_params binds.map { |col, val|
type_cast(val, col)
}
end
ActiveRecord::Result.new(cols, stmt.to_a)
end
end Related methods
- Instance methods
- adapter_name
- add_column
- begin_db_transaction
- change_column
- change_column_default
- change_column_null
- clear_cache!
- columns
- commit_db_transaction
- create
- create_savepoint
- delete_sql
- disconnect!
- empty_insert_statement_value
- exec_delete
- exec_query
- exec_update
- execute
- indexes
- insert_sql
- last_inserted_id
- native_database_types
- primary_key
- quote_column_name
- quote_string
- quoted_date
- release_savepoint
- remove_column
- remove_columns
- remove_index!
- rename_column
- rename_table
- requires_reloading?
- rollback_db_transaction
- rollback_to_savepoint
- select_rows
- supports_add_column?
- supports_autoincrement?
- supports_count_distinct?
- supports_ddl_transactions?
- supports_migrations?
- supports_primary_key?
- supports_savepoints?
- supports_statement_cache?
- tables
- type_cast
- update_sql
- valid_alter_table_options
- Class methods
- new
- visitor_for
- Protected methods
-
alter_table -
copy_table -
copy_table_contents -
copy_table_indexes -
default_primary_key_type -
move_table -
select -
sqlite_version -
table_structure -
translate_exception