我正在使用symfony 1.4 &原理開展一個項目。 1.2員工上的symfony/doctrine getOrganisation()返回一個字符串(但我想要一個對象)
以我的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
,此(重新)創建具有根據表和PHP類數據庫的schema.yml。
所以當我現在做$employee->getOrganization()
(假設$員工是班級員工),我希望得到一個班級組織的對象。但是我得到一個字符串與組織的id字段的內容。 當我以相反方式嘗試時:$organization->getEmployee()
(假設$組織是班級組織),它會向所有員工返回一個Doctrine_Collection。如何getOrganization()
返回組織對象?
不要被格雷德重申「組織」爲「組織」(在北美以外的首選拼寫) - 這是無關緊要的。 –
@Colin Fine:哈哈,好吧,但我在NA之外,更喜歡z。 :P – Mathias
@Colin oops ...抱歉... ;-)甚至不知道z被允許... –