lib/kit/db_sqlite3.rb in kit-0.1.0 vs lib/kit/db_sqlite3.rb in kit-0.1.1
- old
+ new
@@ -129,11 +129,11 @@
# Gets the row from an info table with the given id.
# @param [Symbol] table what database table to query
# @param [Array] fields list of column names to return
# @param [Integer] id rowid of record to return
- # @return [Array] hash for each returned row with a key for each requested field
+ # @return [Hash] first matched row with a key for each requested field
def select_info_by_id table, fields, id
info = @info_db.select fields, "FROM `#{table}` WHERE `rowid` = '#{id}'"
info.first
end
@@ -149,18 +149,17 @@
# Gets the rows from an info table with the given criteria.
# @param table (see #select_info_by_id)
# @param fields (see #select_info_by_id)
# @param [Hash] criteria key / value pairs required to match
- # @return (see #select_info_by_id)
+ # @return [Array] hash for each returned row with a key for each requested field
def select_info_by_criteria table, fields, criteria
q = []
criteria.each do |key, value|
q << "`#{key}` = '#{value}'"
end
info = @info_db.select fields, "FROM `#{table}` WHERE #{q.join " AND "}"
- info.first
end
# Inserts a new row into an info table.
# @param table (see #select_info_by_id)
# @param [Hash] data key / value pairs for new row