Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从JOIN访问与条令相关的字段_Php_Symfony1_Doctrine - Fatal编程技术网

Php 从JOIN访问与条令相关的字段

Php 从JOIN访问与条令相关的字段,php,symfony1,doctrine,Php,Symfony1,Doctrine,我正试图从我的数据库中提取一个使用条令的用户列表,并加入一个连接。我的模型中有以下功能: public function getAttendees() { $q = Doctrine_Query::create() ->select('a.id, a.name, a.url, m.id') ->from('Attendees a') ->leftJoin('a.Meetings m WITH m.Meeting_Slot_

我正试图从我的数据库中提取一个使用条令的用户列表,并加入一个连接。我的模型中有以下功能:

public function getAttendees() {
    $q = Doctrine_Query::create()
        ->select('a.id, a.name, a.url, m.id')
        ->from('Attendees a')
        ->leftJoin('a.Meetings m WITH m.Meeting_Slot_ID = ?', $this->getId());

    return $q->execute();
}
我已经检查了这个查询生成的SQL,它正在处理我想要的所有数据。我现在正在尝试访问检索到的数据。我有以下工作:

foreach($object0>getAttendees() as $attendee){
    echo $attendee->getName();
}

但是,我不知道如何访问m.id字段。

我认为您可以这样做:

$attendee->getMeetings()->getId()
必须使用schema.yml中定义的别名(如果使用的是symfony) 通常,条令使用这种方式将相关模型链接在一起: 模型1->模型2->模型3
…->getModel2()->getModel3()->getModel3Field()

$attendee->getMeeting()->getId()或soemthing会产生这种效果。

实际上,getMeetings()会返回一个会议数组,因为这是一个一对多关系。