1

ORMとしてsymfony1.4とPropelを使用しています。他のフォームを埋め込む必要のあるフォームがあります。もう1つの形式は、顧客とオブジェクトを接続するn:m関係です。顧客のすべてのオブジェクトを表示するように埋め込む方法がわかりません。

次のスキーマを考慮して、CustomerCountryGroupフォームをCustomerフォームに埋め込み、ユーザーに関連するCuountryGroupオブジェクトのリストを表示したいと思います。

これが私のschema.ymlです:

Customer:
  _attributes: { phpName: Customer }
  id:
    phpName: Id
    type: INTEGER
    size: '11'
    primaryKey: true
    autoIncrement: true
    required: true

CustomerCountryGroup:
  _attributes: { phpName: CustomerCountryGroup }
  id:
    phpName: Id
    type: INTEGER
    size: '10'
    primaryKey: true
    autoIncrement: true
    required: true
  customerId:
    phpName: CustomerId
    type: INTEGER
    size: '10'
    required: false
    foreignTable: Customers
    foreignReference: id
    onDelete: CASCADE
    onUpdate: RESTRICT
  countryGroupId:
    phpName: CountryGroupId
    type: INTEGER
    size: '10'
    required: false
    foreignTable: CountryGroups
    foreignReference: id
    onDelete: CASCADE
    onUpdate: RESTRICT

CountryGroup:
  _attributes: { phpName: CountryGroup }
  id:
    phpName: Id
    type: INTEGER
    size: '11'
    primaryKey: true
    autoIncrement: true
    required: true

この問題のチュートリアル/解決策をどこで見つけることができるか知っていますか?

どうもありがとう

4

1 に答える 1

2

埋め込みが意味するのであれば、Symfonyは複数の選択を生成する必要があります。これは、実際に顧客から国を編集できるのとは対照的です。参照テーブルのIDをPKとして設定する必要があると思います。そうすれば、symfonyがその役割を果たします。

CustomerCountryGroup:
  _attributes: { phpName: CustomerCountryGroup }
  customerId:
    phpName: CustomerId
    type: INTEGER
    required: true
    primaryKey: true
    foreignTable: Customers
    foreignReference: id
    onDelete: CASCADE
    onUpdate: CASCADE
  countryGroupId:
    phpName: CountryGroupId
    type: INTEGER
    required: true
    primaryKey: true
    foreignTable: CountryGroups
    foreignReference: id
    onDelete: CASCADE
    onUpdate: CASCADE
于 2011-02-15T21:48:43.383 に答える