I was going through the Zend Framework quickstart tutorial, and in their demo code they use a data mapper which uses Zend_DB_Table to access the database (see: http://framework.zend.com/manual/en/learning.quickstart.create-model.html). It seems that Zend_DB_Table doesn't use prepared statements or provide a way to use transactions though. Therefore, I'm leaning towards just using a datamapper directly with a zend_db_adapter. With that in mind, can someone advise as to the situations where Zend_DB_Table would be advantageous? Appreciate your input! Cheers.
3条回答 默认 最新
- duanchen1937 2011-02-25 11:00关注
In general, I see
Zend_Db_Table
as a quick and easy way to do single-table queries.You can surely do joins with
Zend_Db_Table
, but since the class is targeted towards a specific table (after all, it is intended as a Table Data Gateway implementation), all such joins always feel - to me, at least - like an unnatural graft. In that case, I always tend towards straight adapter-based queries with joins, that could include your transaction handling.Of course, in either case, it is certainly desirable to put all of this behind a model or mapper or service layer. Then, as you change these implementation details- say, start out with a
Zend_Db_Table
implementation, but later realize you need to join data from a another table, so you move to adapter-based queries - none of this will affect consumers of the model/mapper/service.Hope this helps.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何绘制动力学系统的相图
- ¥15 对接wps接口实现获取元数据
- ¥20 给自己本科IT专业毕业的妹m找个实习工作
- ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
- ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
- ¥50 mac mini外接显示器 画质字体模糊
- ¥15 TLS1.2协议通信解密
- ¥40 图书信息管理系统程序编写
- ¥20 Qcustomplot缩小曲线形状问题
- ¥15 企业资源规划ERP沙盘模拟