douchuang1852 2018-07-20 09:34
浏览 15

MVC:哪个MVC层对于这个方法是正确的?

I have a method that build a Child Object list for each parent Object.Here is my code:

class Element{
    function getChilList($child){
      Element parentDataObject[];
      if(count($this->parentDataObject)>0)              
            foreach ($this->parentDataObject as $c){    
               $this->parentDataObject[] =  $c;
               $this->TryAddAsSubProject($c);
            }
    }
}

based on that list, i have to display all parent with their child in the View But i was confused that, on which Layer of MVC (Model/View/Controller) to put this code so the parent View Layer can easily get all Child List.And another thing is that if i need a List child of in each parent class of same type, then is it violating the property of MVC pattern? that is please suggest correct one.Thanks

  • 写回答

1条回答 默认 最新

  • dougu5847 2018-07-20 10:36
    关注

    This class should reside in a the business layer. Another option is putting this code in a Data Access Layer (DAL) and then call it from the business layer to get the data and do further processing if necessary. Eventually the business layer code will be called from the controller.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度