我有一个像这样的doctrine2查询:
$query = $this -> doctrine -> em -> createQuery ("SELECT a, b FROM ORM\Dynasties2\Maillinks a JOIN a.msgId b");
返回mixed results,类似于:
ORM\Dynasties2\Maillinks Object
(
[id:ORM\Dynasties2\Millinks:private] => 1
[toUser:ORM\Dynasties2\Maillinks:private] => 16
[isRead:ORM\Dynasties2\Maillinks:private] => 0
[msgId:ORM\Dynasties2\Maillinks:private] => ORM\Dynasties2\Mailmsgs Object
(
[id:ORM\Dynasties2\Mailmsgs:private] => 1
[msgText:ORM\Dynasties2\Mailmsgs:private] => asdfasdfasdfasdfasdfasdf
[fromUser:ORM\Dynasties2\Mailmsgs:private] => 13
[timeStamp:ORM\Dynasties2\Mailmsgs:private] => DateTime Object
(
[date] => 2012-04-20 12:17:29
[timezone_type] => 3
[timezone] => America/Los_Angeles
)
[onTurn:ORM\Dynasties2\Mailmsgs:private] => 1
[importance:ORM\Dynasties2\Mailmsgs:private] => 2
[msgType:ORM\Dynasties2\Mailmsgs:private] => 1
)
)
我可以轻松地访问“顶部”的一些数据
echo $row -> getToUser();
返回“16”
我尝试echo $row -> msgId-> getMsgText();
,但返回Fatal error: Cannot access private property ORM\Dynasties2\Maillinks::$msgId
如何访问
中对象中的数据或者:我的查询和结果是否已损坏?我是否需要对我的查询或实体做一些不同的事情?
答案 0 :(得分:2)
这不适合你吗?
$row->getMsgId()->getMsgText();
您应该能够检查实际的实体文件(无论是否有构建它们的学说,或其他人做过)来检查该实体的getter和setter。