Sha256: 851dc9f048483a00f837ac76fbc23e05558a8892edf94e994daf7a68e375383f

Contents?: true

Size: 1.78 KB

Versions: 24

Compression:

Stored size: 1.78 KB

Contents

class Hayabusa::Models::Log_access < Knj::Datarow
  def get
    return data_hash("get")
  end
  
  def post
    return data_hash("post")
  end
  
  def meta
    return data_hash("meta")
  end
  
  def cookie
    return data_hash("cookie")
  end
  
  def ips
    return data_array(self[:ip_data_id])
  end
  
  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
  
  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
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
hayabusa-0.0.28 lib/models/log_access.rb
hayabusa-0.0.25 lib/models/log_access.rb
hayabusa-0.0.24 lib/models/log_access.rb
hayabusa-0.0.23 lib/models/log_access.rb
hayabusa-0.0.22 lib/models/log_access.rb
hayabusa-0.0.20 lib/models/log_access.rb
hayabusa-0.0.19 lib/models/log_access.rb
hayabusa-0.0.18 lib/models/log_access.rb
hayabusa-0.0.17 lib/models/log_access.rb
hayabusa-0.0.16 lib/models/log_access.rb
hayabusa-0.0.15 lib/models/log_access.rb
hayabusa-0.0.14 lib/models/log_access.rb
hayabusa-0.0.13 lib/models/log_access.rb
hayabusa-0.0.12 lib/models/log_access.rb
hayabusa-0.0.11 lib/models/log_access.rb
hayabusa-0.0.10 lib/models/log_access.rb
hayabusa-0.0.9 lib/models/log_access.rb
hayabusa-0.0.8 lib/models/log_access.rb
hayabusa-0.0.6 lib/models/log_access.rb
hayabusa-0.0.5 lib/models/log_access.rb