# To change this template, choose Tools | Templates
# and open the template in the editor.

class AbstractAbfrageController < ApplicationController
  def where_equals(wert, spalte)
    unless wert.blank?
      @conditions += " AND #{spalte} = ?"
      @condition_parameters << wert.strip
    end
  end

  def where_int(wert, spalte)
    if wert.strip =~ /^\d+$/
      @conditions += " AND #{spalte} = ?"
      @condition_parameters << wert.strip.to_i
    end
  end

  def where_like(wert, spalte)
    unless wert.blank?
      @conditions += " AND #{spalte} ILIKE ?"
      @condition_parameters << "%#{wert.strip}%"
    end
  end

  def where_smaller(wert, spalte)
    unless wert.blank?
      @conditions += " AND #{spalte} < ?"
      @condition_parameters << wert.to_i
    end
  end

  def where_greater(wert, spalte)
    unless wert.blank?
      @conditions += " AND #{spalte} > ?"
      @condition_parameters << wert.to_i
    end
  end
end
