2

我也有课程和两个非 TYPO3 表。我将非 TYPO3 表定义为没有 uid、pid 等列的表。

我的两个班:

  1. Tx_Abc_Domain_Model_Location 类扩展 Tx_Extbase_DomainObject_AbstractEntity
  2. 类 Tx_Abc_Domain_Model_Facility 扩展了 Tx_Extbase_DomainObject_AbstractEntity

我的两个表(带列):

  1. 地点
    • 邮政编码
    • 城市
    • 设施 ID
  2. 设施
    • 设施 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 查找位置时,它为我构建了一个包含设施模型的位置模型。

The problem appears, when I the search I am doing returns several results. i.e. the location with the zipcode 12345 has two different facilities (and the table locations got two rows with different facility_ids), then I would expect to get two location models and each of it got the right facility model.

But instead I get the two location models, which have all same facility model inside. They've got all the facility of the first found location.

Even if I change the type of the facility attribute to integer, there are the wrong ids. But if I enable raw query result in repository I get the correct ids.

I get also the correct ids or models, when I add to both tables an uid-column.

Is there no possibility to map tables without uid column with Extbase models?

Thanks.

4

2 回答 2

3

Okay, the answer to my last question is: Yes, there is no possibility to map tables without uid column with Extbase models.

There is an existing ticket on forge: http://forge.typo3.org/issues/25984

The reason seems to be the hardcoded $row['uid'] in mapSingleRow() method in Tx_Extbase_Persistence_Mapper_DataMapper class.

于 2013-03-21T09:22:59.713 回答
1

If it's not alot of tables you have to map, a work-around could be to create views for those tables to just map the uid.

I.e.:

CREATE VIEW tx_abc_domain_model_facility AS
    SELECT facility_id AS uid, facilities.* FROM facilities;
于 2013-07-23T08:08:11.243 回答