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 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示