我也有类(class)和两个非 TYPO3 表。我将非 TYPO3 表定义为没有 uid、pid 等列的表。
我的两门课:
- Tx_Abc_Domain_Model_Location 类扩展了 Tx_Extbase_DomainObject_AbstractEntity
- 类 Tx_Abc_Domain_Model_Facility 扩展了 Tx_Extbase_DomainObject_AbstractEntity
我的两个表格(带列):
- 地点
- 邮政编码
- 城市
- facility_id
- 设施
- facility_id
- 姓名
我已经映射了如下属性:
config.tx_extbase.persistence.classes {
Tx_Abc_Domain_Model_Location.mapping {
tableName = locations
columns {
zipcode.mapOnProperty = zipcode
city.mapOnProperty = city
facility_id.mapOnProperty = facility
}
}
Tx_Abc_Domain_Model_Facility.mapping {
tableName = facilities
columns {
facility_id.mapOnProperty = uid
name.mapOnProperty = name
}
}
}
我的问题:
我的位置模型的设施属性的类型为Tx_Abc_Domain_Model_Facility
,当我通过 LocationRepository 查找位置时,它会为我构建一个包含设施模型的位置模型。
当我正在进行的搜索返回多个结果时,问题就出现了。即邮政编码 12345 的位置有两个不同的设施(并且表位置有两行具有不同的facility_ids),那么我希望获得两个位置模型,并且每个模型都有正确的设施模型。
但是我得到了两个位置模型,它们内部都有相同的设施模型。他们拥有第一个找到的位置的所有设施。
即使我将设施属性的类型更改为整数,也会出现错误的 ID。但是,如果我在存储库中启用原始查询结果,我会得到正确的 ID。
当我向两个表添加 uid 列时,我还会得到正确的 id 或型号。
是否无法将没有 uid 列的表与 Extbase 模型进行映射?
谢谢。
最佳答案
好吧,我最后一个问题的答案是:是的,不可能将没有 uid 列的表与 Extbase 模型进行映射。
forge 上有一张现有票证:http://forge.typo3.org/issues/25984
原因似乎是 Tx_Extbase_Persistence_Mapper_DataMapper 类中的 mapSingleRow() 方法中的硬编码 $row['uid']
。
关于model-view-controller - 带有非 TYPO3 表的 Extbase 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15531266/