Top Level Namespace
- Includes:
- Helper
Defined Under Namespace
Modules: Helper Classes: Mysql
Instance Method Summary collapse
-
#cdb(*args) ⇒ Object
操作入口.
-
#defind_model(*args) ⇒ Object
(also: #dm)
定义一个model类,对应到数据库中的表.
Methods included from Helper
Instance Method Details
#cdb(*args) ⇒ Object
操作入口
29 30 31 32 33 |
# File 'lib/mrlic.rb', line 29 def cdb(*args) mysql = Mysql.new *args; mysql.connect puts "0k" end |
#defind_model(*args) ⇒ Object Also known as: dm
定义一个model类,对应到数据库中的表
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mrlic.rb', line 9 def defind_model *args class_name = args[0] log_ok "要操作的类是:#{class_name}" table = args[1] || "#{class_name}s" log_ok "要操作的数据库表是:#{table}" primary_key = args[2] || "id" log_ok "表:#{table} 的主键是:#{primary_key}" eval <<-EOF class #{class_name} < ActiveRecord::Base self.table_name = \"#{table}\"; self.primary_key = \"#{primary_key}\" end EOF end |