Class: Knjappserver::Log_data_value

Inherits:
Knj::Datarow
  • Object
show all
Defined in:
lib/include/class_log_data_value.rb

Class Method Summary collapse

Class Method Details

.force(d, value) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/include/class_log_data_value.rb', line 2

def self.force(d, value)
	value_obj = d.ob.get_by(:Log_data_value, {
		"value" => value.to_s
	})
	
	if !value_obj
		value_obj = d.ob.add(:Log_data_value, {"value" => value})
	end
	
	return value_obj
end

.force_id(d, value) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/include/class_log_data_value.rb', line 14

def self.force_id(d, value)
   d.db.select(:Log_data_value, {"value" => value}) do |d_val|
     return d_val[:id].to_i if d_val[:value].to_s == value.to_s #MySQL doesnt take upper/lower-case into consideration because value is a text-column... lame! - knj
   end
   
   return d.db.insert(:Log_data_value, {:value => value}, {:return_id => true}).to_i
end