Sha256: c14374a97ed222cc4586b632557fe82bb2094a5de00af317e1b5e5a2023c4c5d

Contents?: true

Size: 916 Bytes

Versions: 2

Compression:

Stored size: 916 Bytes

Contents

class Connect < ActiveRecord::Base
  has_many :reports

  def exec(sql)
    result = []
    if (self.adapter==Treport::Db::AdapterType[:Oracle])
      result = Treport::Db.oracle_query self.serializable_hash, sql
    elsif (self.adapter==Treport::Db::AdapterType[:Mysql])
      result = Treport::Db.mysql_query self.serializable_hash, sql
    elsif (self.adapter==Treport::Db::AdapterType[:Sqlserver])
      result = Treport::Db.sqlserver_query self.serializable_hash, sql
    end
    return result
  end

  def self.connect_options
    Connect.all.map { |c| [c.name, c.id] }
  end

  def adapter_name
    return "Mysql" if self.adapter == Treport::Db::AdapterType[:Mysql]
    return "PostgreSQL" if self.adapter == Treport::Db::AdapterType[:PostgreSQL]
    return "Oracle" if self.adapter == Treport::Db::AdapterType[:Oracle]
    return "Sqlserver" if self.adapter == Treport::Db::AdapterType[:Sqlserver]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
treport-0.2.0 app/models/connect.rb
treport-0.1.0 app/models/connect.rb