我有一个这样的学说2查询:
$query = $this -> doctrine -> em -> createQuery ("SELECT a, b FROM ORM\Dynasties2\Maillinks a JOIN a.msgId b");
它返回混合结果,类似于:
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
如何访问对象中的数据?
或者:我的查询和结果是否损坏?我需要对我的查询或实体做一些不同的事情吗?