Hi,

I've been playing around with using DBI instead of ActiveRecord 'cause
I just love to beat myself up!  ;)  Is this an okay way to do this, or
is there any other more creative ways?

require 'dbi'

module MyApp:Models
  class DB
    def self.dbh
      DBI.connect('DBI:Mysql:dbname', 'username', 'password')
    end
  end

  class Category < DB
    def self.find
      dbh.select_all('SELECT * FROM myapp_categories')
    end

    def self.find_by_id(id)
      dbh.select_all('SELECT * FROM myapp_categories WHERE id = ?', id)
    end
  end
end

module MyApp:Controllers
  class Index < R '/'
    def get
      @categories = Category.find
      render :index
    end
  end
end
_______________________________________________
Camping-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to