douyinliu8813 2013-04-21 08:52 采纳率: 100%
浏览 61
已采纳

在Model中实例化对象并使用CakePHP中的Model值返回对象有什么问题吗?

Like performance issues or something? Basically I will have some Views whose data will be coming in across different models and I just want to have the data sent back to be the ones that I need, and really don't like the arrays CakePHP models send back.

So just get the aggregate data, transform it and populate the object then send that back to the controller to pass on to the view.

Yes it's extra work but if it doesn't cause any issues, I think it'll be worth it.

So any problems with this way of doing things? Thanks.

  • 写回答

1条回答 默认 最新

  • douhe4608 2013-04-22 06:36
    关注

    Converting to objects would be small overhead but shouldn't pose any major issues performance wise. Though it could make maintaining the app difficult for others like burzum commented. By augmenting the way the framework works you will lose lot of its benefits. Eg. passing objects to views means the helpers won't be able to do any "magic". If you dislike the fact that CakePHP's models return arrays then perhaps you should not be using CakePHP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 nslt的可用模型,或者其他可以进行推理的现有模型
  • ¥15 arduino上连sim900a实现连接mqtt服务器
  • ¥15 vncviewer7.0安装后如何正确注册License许可证,激活使用
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并2
  • ¥66 关于人体营养与饮食规划的线性规划模型
  • ¥15 基于深度学习的快递面单识别系统
  • ¥15 Multisim仿真设计地铁到站提醒电路
  • ¥15 怎么用一个500W电源给5台60W的电脑供电
  • ¥15 请推荐一个轻量级规则引擎,配合流程引擎使用,规则引擎负责判断出符合规则的流程引擎模板id
  • ¥15 Excel表只有年月怎么计算年龄