【发布时间】:2011-11-15 08:44:15
【问题描述】:
我正在使用 symfony 1.4 和学说进行项目。 1.2
在我的 schema.yml 中,我定义了一个员工和一个组织实体:
employee:
tableName: employee
columns:
id:
primary: true
type: integer(8)
notnull: true
autoincrement: true
organization:
default: NULL
type: integer
relations:
organization:
onDelete: restrict
local: organization
foreign: id
organization:
tableName: organization
columns:
id:
primary: true
unique: true
type: integer
notnull: true
autoincrement: true
relations:
employee:
type: many
class: employee
local: id
foreign: organization
然后我运行命令symfony doctrine:build --all --and-load,这(重新)根据 schema.yml 创建包含表和 php 类的数据库。
所以当我现在做$employee->getOrganization()(假设$employee 是班级雇员)时,我希望得到班级组织的对象。但我得到一个包含组织 id 字段内容的字符串。
当我反过来尝试时:$organization->getEmployee()(假设 $organization 是类组织)它返回一个包含所有员工的 Doctrine_Collection。
我如何getOrganization()返回组织对象?
【问题讨论】: