dsovc00684 2013-04-12 05:07
浏览 33

Yii框架 - 改变数据库

I just migrate to yii and i created a model which it created an CActiveRecord with gii and after that i make some changes in database then it make me confused, now my question is :

1 - Should i recreate Model with gii after any change to database ? Why Active record in yii is much complicated than other frameworks like zend or codigniter !?

Edit :

If we should not change Model Class, where should we put our database functions !!? aren't Model is there for doing so?

  • 写回答

4条回答 默认 最新

  • dongwenghe2416 2013-04-12 05:14
    关注

    I think, You should ideally recreate the model after DB structural changes.

    In our project, We are following the rule,

    Do not make any changes in the models generated by gii. So that if there are DB changes in future, we could directly regenerate the models and will have no merging efforts.

    This is also inline with philosophy of design,

    **Objects** hide their data behind abstractions and expose functions that operate on that data.
    
    **Data structures**
    expose their data and have no meaningful functions. It only has methods to operate on data.
    

    ActiveRecords(models in yii) are nothing but data structures.By adding business rules in ActiveRecords, you are mixing your data structures and objects.

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献