The Model 家庭

对于任何 的MVC 框架 你应该找一个 模型 定义 的地方 ,以及 一些“ 资源模型 “的形式. In Magento,在model家庭里面有3个成员,分别是:

The Model, the Resource Model, and the Collection Model.当我们需要它的时候,这3个成员  相互工作给我们想要的数据。

 

在之前 我们已经讨论了 创建模型 我们会 进入一个 资源模型 和集合 模型。

As I see it:

  一个 “模型” 是用来 存储数据 ,也许 这些数据 进行一些 业务逻辑
“资源 模型 “是用来 互动的 “模式”的 代表 数据库( 持久性 数据 或者 其他形式) “资源 模式“ 是一个 实际执行 CRUD操作。
一个 “collection 模式“ 持有 1对多 “模式” ,并且知道 如何
基于 行的 “资源 模型“ 来获取 其他更多相关的 信息 群。

 

下面, 试图说明 它们是如何 连在一起:

正如 Magento的 大多数事情一样, 整个事情 开始于 config.xml中。 正是在 这里, 我们定义 在哪里找 我们的模型 资源模型 我们的资源 哪些表 间相互作用。 这里是 config.xml中 定义 这些事情 的一个片段:

< global >
         < models >
             < awesome >
                 < class > Yt _Awesome_Model</ class >
                 < resourceModel >awesome_mysql4</ resourceModel >
             </ awesome >
             < core >
                 < rewrite >
                     < translate > Yt _Awesome_Model_Translate</ translate >
                 </ rewrite >
              </ core >
              < awesome_mysql4 >
                 < class > Yt _Awesome_Model_Mysql4</ class >
                 < entities >
                     < example >
                         < table > Yt _awesome_example</ table >
                     </ example >
                 </ entities >
             </ awesome_mysql4 >
         </ models >
 
         < resources >
             < awesome_setup >
                 < setup >
                     < module > Yt _Awesome</ module >
                 </ setup >
                 < connection >
                     < use >core_setup</ use >
                 </ connection >
             </ awesome_setup >
             < awesome_write >
                 < connection >
                     < use >core_write</ use >
                 </ connection >
             </ awesome_write >
             < awesome_read >
                 < connection >
                     < use >core_read</ use >
                 </ connection >
             </ awesome_read >
         </ resources >
</ global >

Yt
|_ Awesome
|_Model
|_Mysql4
| |_Example
| | |_Collection.php (Yt_Awesome_Model_Mysql4_Example_Collection)
| |_Example.php (Yt_Awesome_Model_Mysql4_Example)
|_Example.php (Yt_Awesome_Model_Example)

Yt_Awesome_Model_Example is the "model"
Yt_Awesome_Model_Mysql4_Example is the "resource model"
Yt_Awesome_Model_Mysql4_Example_Collection is the "collection model"

 

 

未完待续.......

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
GOAL Perform a Poisson regression to predict the number of people in a househouse based on the age of the head of the household. DATA The Philippine Statistics Authority (PSA) spearheads the Family Income and Expenditure Survey (FIES) nationwide. The survey, which is undertaken every three years, is aimed at providing data on family income and expenditure, including levels of consumption by item of expenditure. The data, from the 2015 FIES, is a subset of 1500 of the 40,000 observations (Philippine Statistics Authority 2015). The data set focuses on five regions: Central Luzon, Metro Manila, Ilocos, Davao, and Visayas. The data is in the file fHH1.csv. Each row is a household, and the follow variables are recorded: • location: where the house is located (Central Luzon, Davao Region, Ilocos Region, Metro Manila, or Visayas) • age: the age of the head of household • total: the number of people in the household other than the head • numLT5: the number in the household under 5 years of age • roof: the type of roof in the household (either Predominantly Light/Salvaged Material, or Predominantly Strong Material. STEPS 1. Read in the dataset. 2. Produce a bar-chart of total 3. Produce a scatter-plot of total against age - add a smoothing line. 4. Fit the Poisson regression total ∼ age 5. Interpret the coefficient of age. 6. Obtain the Pearson residuals. Plot these against age. Is the model adequate? 7. Fit the Poisson regression total ∼ age + age2 8. Repeat the residual plots for the new model. 9. Compare the models using a likelihood ratio test, and AIC. 10. Calculate the predicted values for model M2. What is the age of the head of the household associated with the largest fitted value 使用R语言
05-26

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值