在Symfony 1.4中,Doctrine我有来自schema.yml的这个片段
Attendance:
columns:
id: { type: integer(4), primary: true, autoincrement: true }
user_id: { type: integer(4) }
relations:
JoomlaUser: { class: JosUser, local: user_id, foreignAlias: AttendanceList }
和
JosUser:
tableName: jos_users
columns:
id: { type: integer(4), primary: true, autoincrement: true }
relations:
AttendanceList: { class: Attendance, local: id, foreign: user_id }
从JosUser确定没有出勤记录的最有效方法是什么?我尝试过model / doctrine / JosUser.class.php
count($this->getAttendanceList())
但是这会返回一个Doctrine Record,所有字段都为空但user_id
答案 0 :(得分:1)
架构:
JosUser:
tableName: jos_users
columns:
id: { type: integer(4), primary: true, autoincrement: true }
relations:
AttendanceList: { type: many, class: Attendance, local: id, foreign: user_id }
使用type: many
,getAttendanceList()
应该返回一个Doctrine_Collection(参见lib / model / doctrine / base / BaseJosUser.class.php中的JosUser基类),然后你可以使用
$this->getAttendanceList()->count()