【发布时间】:2025-12-31 06:40:16
【问题描述】:
这是我的问题和我的表格:
**sales_person**
id | sp_number | name
31 | 23948223 | John Doe
**Team**
id | name | parent_id | lft | rght
52 | Super Team | 1 | 1 | 2
**Team_Salesmen**
id | team_id | sales_person_id
1 | 52 | 31
所以我有我的销售人员、我的团队和一张表格来显示哪些销售人员属于哪些团队。
我打算显示一个团队所有子团队的列表,然后列出他们所有的销售人员。
Teams 通过 team_id 与 Team_salesmen 相关联,因此我可以对其进行包含。问题是,这只返回 Team_salesmen 实体 'id:1, team_id:52, sales_person_id:31',而我需要它来返回推销员的姓名和号码。
因此,在 Teams 模型中,我需要包含 TeamSalesmen,然后包含从 TeamSalesmen 到 SalesPerson。如何链接命令? CakePHP 认为我正在尝试将 Teams 包含在 SalesPersons 中,它们没有直接关系。
【问题讨论】:
标签: mysql query-builder cakephp-3.0