av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

Ruby框架OG與ActiveRecord不同之處

我們通過對Ruby語言的深入學(xué)習(xí)中知道,有兩種ORM框架可以幫助我們靈活的編寫Ruby語言。下面我們將會(huì)介紹其中一種ORM框架,Ruby框架OG。#t#

當(dāng)我們需要定義一個(gè)存儲(chǔ)的類時(shí),我們能夠使用property方法使用Ruby框架OG:

  1. classSomeClass  
  2. property:alpha,String  
  3. property:beta,String  
  4. property:gamma,String  
  5. end 

Ruby框架OG連接數(shù)據(jù)庫:

 
 
 
  1. db=Og::Database.new
    (:destroy=>false,  
  2. :name=>'mydb',  
  3. :store=>:mysql,  
  4. :user=>'hal9000',  
  5. :password=>'chandra') 

每一個(gè)對象都有一個(gè)save方法來插入數(shù)據(jù)庫數(shù)據(jù):

 
 
 
  1. obj=SomeClass.new  
  2. obj.alpha="Poole" 
  3. obj.beta="Whitehead" 
  4. obj.gamma="Kaminski" 
  5. obj.save 

還有一些描述傳統(tǒng)數(shù)據(jù)庫中的對象關(guān)系的Ruby框架OG使用方法:

 
 
 
  1. classDog  
  2. has_one:house  
  3. belongs_to:owner  
  4. has_many:fleas  
  5. end  

網(wǎng)頁標(biāo)題:Ruby框架OG與ActiveRecord不同之處
文章位置:http://uogjgqi.cn/article/djpdcec.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們在微信上24小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流