class MiniSql::Connection
Public Class Methods
get(raw_connection, options = {})
click to toggle source
# File lib/mini_sql/connection.rb, line 6 def self.get(raw_connection, options = {}) if (defined? ::PG::Connection) && (PG::Connection === raw_connection) Postgres::Connection.new(raw_connection, options) elsif (defined? ::ArJdbc) Postgres::Connection.new(raw_connection, options) elsif (defined? ::SQLite3::Database) && (SQLite3::Database === raw_connection) Sqlite::Connection.new(raw_connection, options) elsif (defined? ::Mysql2::Client) && (Mysql2::Client === raw_connection) Mysql::Connection.new(raw_connection, options) else raise ArgumentError, 'unknown connection type!' end end
Public Instance Methods
build(sql)
click to toggle source
# File lib/mini_sql/connection.rb, line 54 def build(sql) Builder.new(self, sql) end
escape_string(str)
click to toggle source
# File lib/mini_sql/connection.rb, line 58 def escape_string(str) raise NotImplementedError, "must be implemented by child connection" end
exec(sql, *params)
click to toggle source
# File lib/mini_sql/connection.rb, line 50 def exec(sql, *params) raise NotImplementedError, "must be implemented by child connection" end
query(sql, *params)
click to toggle source
# File lib/mini_sql/connection.rb, line 30 def query(sql, *params) raise NotImplementedError, "must be implemented by child connection" end
query_decorator(sql, *params)
click to toggle source
# File lib/mini_sql/connection.rb, line 38 def query_decorator(sql, *params) raise NotImplementedError, "must be implemented by child connection" end
query_each(sql, *params)
click to toggle source
# File lib/mini_sql/connection.rb, line 42 def query_each(sql, *params) raise NotImplementedError, "must be implemented by child connection" end
query_each_hash(sql, *params)
click to toggle source
# File lib/mini_sql/connection.rb, line 46 def query_each_hash(sql, *params) raise NotImplementedError, "must be implemented by child connection" end
query_hash(sql, *params)
click to toggle source
# File lib/mini_sql/connection.rb, line 34 def query_hash(sql, *params) raise NotImplementedError, "must be implemented by child connection" end
query_single(sql, *params)
click to toggle source
Returns a flat array containing all results. Note, if selecting multiple columns array will be flattened
@param sql [String] the query to run @param params [Array or Hash], params to apply to query @return [Object] a flat array containing all results
# File lib/mini_sql/connection.rb, line 26 def query_single(sql, *params) raise NotImplementedError, "must be implemented by child connection" end