Class: Knjappserver::Log_access

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

Instance Method Summary collapse

Instance Method Details



14
15
16
# File 'lib/include/class_log_access.rb', line 14

def cookie
	return data_hash("cookie")
end

#data_array(data_id) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/include/class_log_access.rb', line 22

def data_array(data_id)
	sql = "
		SELECT
			value_value.value AS value
		
		FROM
			Log_data_link AS value_links,
			Log_data_value AS value_value
		
		WHERE
			value_links.data_id = '#{data_id}' AND
			value_value.id = value_links.value_id
		
		ORDER BY
			key_links.no
	"
	
	arr = []
	q_array = db.query(sql)
	while d_array = q_array.fetch
		arr << d_array[:value]
	end
	
	return arr
end

#data_hash(type) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/include/class_log_access.rb', line 48

def data_hash(type)
	col_keys_id = "#{type}_keys_data_id".to_sym
	col_values_id = "#{type}_values_data_id".to_sym
	
	keys_id = self[col_keys_id]
	values_id = self[col_values_id]
	
	keys_data_obj = ob.get(:Log_data, keys_id)
	values_data_obj = ob.get(:Log_data, values_id)
	
	sql = "
		SELECT
			key_value.value AS `key`,
			value_value.value AS value
		
		FROM
			Log_data_link AS key_links,
			Log_data_link AS value_links,
			Log_data_value AS key_value,
			Log_data_value AS value_value
		
		WHERE
			key_links.data_id = '#{keys_id}' AND
			value_links.data_id = '#{values_id}' AND
			key_links.no = value_links.no AND
			key_value.id = key_links.value_id AND
			value_value.id = value_links.value_id
		
		ORDER BY
			key_links.no
	"
	
	hash = {}
	q_hash = db.query(sql)
	while d_hash = q_hash.fetch
		hash[d_hash[:key].to_s] = d_hash[:value]
	end
	
	return hash
end

#getObject



2
3
4
# File 'lib/include/class_log_access.rb', line 2

def get
	return data_hash("get")
end

#ipsObject



18
19
20
# File 'lib/include/class_log_access.rb', line 18

def ips
	return data_array(self[:ip_data_id])
end

#metaObject



10
11
12
# File 'lib/include/class_log_access.rb', line 10

def meta
	return data_hash("meta")
end

#postObject



6
7
8
# File 'lib/include/class_log_access.rb', line 6

def post
	return data_hash("post")
end