首页 > 解决方案 > 用于多连接表的 Active Record 或 DataMapper

问题描述

目前我正在寻找在 php 中重构我的代码以使用 Active Record 或 DataMapper。我有一个复杂的 sql 查询,其中一个表是基础,我将多个表连接到多个级别,即加入另一个表连接到的表。

例如:

Select <list of columns>
from main_table
left join table1
left join table2 as t1
left join table2 as t2
left join table3
left join table4 on table3.key = table4.key
left join ( select * from table5 ) as t3
left join ( select * from table6 where id in ( select id from table7 ) ) as t4
where <conditions>

用什么比较好?活动记录或数据映射器。此外,我希望它可以方便地升级或插入到主表中。并且还做一些显示/输出功能。处理来自用户的输入。

欢迎任何建议。

标签: phpsqlactiverecorddatamapper

解决方案


推荐阅读