doudou348131346 2011-02-12 01:12
浏览 19
已采纳

MVC架构决策 - 如何将现有方法重新分解为控制器/视图和数据库访问

Consider the following scenario:

Page written in classic ASP or PHP, which is rendering a data report (series of HTML tables for simplicity). There is one main database query and then multiple sub queries as the page renders. The report is split into sub panels, which correlate to a sub query. Therefore:

  1. Main database query.
  2. Loop over result.
  3. For each row, execute sub query and render report panel.

How would you architect a similar report using the MVC pattern?

This can be split into two parts:

  1. Efficiency at database level of multiple queries, which are dependent on values from an outer query.
  2. If all data was processed and prepared in the controller, would this also be deemed inefficient if looping within the controller and then again in a view to render. Could sub controllers be used or sub panels, which encapsulate smaller sections of logic i.e. loading data and rendering report panel.

Appreciate this may look a bit vague but I'm interested in how you would approach the solution.

  • 写回答

3条回答 默认 最新

  • drny20290570 2011-06-01 17:11
    关注

    My final solution had all data retrieval in a repository and then various bits were aggregated in the controller ready for display in the view.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥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 牛顿斯科特系数表表示