Sha256: 3310a3f5399d3f4043d20e12161c73babe9771f1d873de6cae0c1a47c88c77b0

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'alfa/support'
require 'alfa/database/mysql'
require 'alfa/models/base_sql'

module Alfa
  module Models
    class MySQL < Alfa::Models::BaseSQL
      include Alfa::ClassInheritance
      inheritable_attributes :connection, :table
      @connection = nil
      @table = nil
      @pk = :id

      def self.register_database database
        raise 'Expected database to be instance of Alfa::Database::MySQL' unless database.ancestors.include? Alfa::Database::MySQL
        @connection = database
      end

      #@return Array || nil
      def self.all
        @connection.query("SELECT * FROM `#{self.table}`")
      end

      def self.find filter = {}

      end

      def self.find_first filter = {}
      end

      def self.count filter = {}
      end

      def self.exists? pk
      end

      def self.create data = {}
      end

      def self.delete pk
      end

      def self.update data = {}
      end

      def self.table
        @table.to_s
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alfa-0.0.1.pre lib/alfa/models/mysql.rb