Method: WIKK::SQL.query

Defined in:
lib/wikk_mysql2.rb,
lib/wikk_ruby_mysql.rb

.query(db_config, the_query) {|@result| ... } ⇒ Mysql::Result

Create WIKK::SQL instance and set up the mySQL connection, and Run a query on the DB server.

Parameters:

  • db_config (Configuration)

    Configuration class, Hash, or any class with appropriate attr_readers.

  • the_query (String)

    Sql query to send to DB server.

Yield Parameters:

  • @result (Mysql::Result)

    and @affected_rows are also set.

Returns:

  • (Mysql::Result)

    @result and @affected_rows are also set.

Raises:

  • (Mysql)

    passes on Mysql errors, freeing the result.



293
294
295
296
297
298
299
300
301
302
303
# File 'lib/wikk_mysql2.rb', line 293

def self.query(db_config, the_query)
  self.connect db_config do |sql|
    result = sql.query(the_query)
    if block_given?
      yield result
      return sql.affected_rows
    else
      return result
    end
  end
end