需要帮助:无法调用Doctrine_Core :: set()... symfony 1.4 fixture

时间:2010-07-20 20:03:00

标签: php symfony1 doctrine symfony-1.4 fixture

我一直得到:无法调用Doctrine_Core :: set(),在设置一对多引用时,第二个参数应该是Doctrine_Collection的实例。

当我在夹具的“上传”表中包含“资产”数据时会发生这种情况。

请参阅下面的schema.yml的一部分:

    
detect_relations: true
options:
  collate: utf8_general_ci
  charset: utf8
  type: InnoDB

Asset:
  actAs: { Timestampable: ~ }
  columns:
    asset_id:
      type: integer
      primary: true
      notnull: true
      autoincrement: true
    asset_type_id:
      type: integer
      notnull: true
    user_id:
      type: integer(4)
      notnull: true
    name:
      type: string(45)


Upload:
  actAs: { Timestampable: ~ }
  columns:
    upload_id:
      type: integer
      primary: true
      notnull: true
      autoincrement: true
    asset_id:
      type: integer
      notnull: true
  relations:
    Asset:
      class: Asset
      local: asset_id
      foreign: asset_id
      foreignAlias: Assets
      type: many
      foreignType: one

以下是Fixture的一部分:

Asset:
  sp_asset1:
    AssetType: Spain
    sfGuardUser: User_1
    name: The great Spanish song
    Category: Category_3
    description: The best Spanish Thing
    preview: http://www.google.com/sample.mp3
  sp_asset2:
    AssetType: British
    sfGuardUser: User_1
    name: The best mountains scok
    Category: Category_3
    description: A great example of British

## the problem happens below ##
Upload:
  Upload_1:
    asset: sp_asset1
  Upload_2:
    asset: sp_asset2

当我在夹具的“上传”表中包含“资产”的数据时会发生这种情况 有没有人知道这个'无法调用Doctrine_Core :: set(),第二个参数......'问题?

2 个答案:

答案 0 :(得分:2)

尝试:

Upload:
  Upload_1:
    asset: [sp_asset1]
  Upload_2:
    asset: [sp_asset2]

答案 1 :(得分:0)

检查名称的大小写。您的关系名为"Asset",您在灯具中使用"asset"。我有类似的问题,这是字母的问题。