我正在尝试从第二个表中获取标题(通过左连接),但我的 resultSet 没有提供连接表的列。
这就是我的 TableGateway 的样子:
public function fetchCourseListWithStudyprogram()
{
$select = $this->getSql()->select();
$select->where->equalTo('course_active', 'Y');
$select->join('studyprogram', 'studyprogram.studyprogram_id = course.studyprogram_id', ['studyprogram_title'], $select::JOIN_LEFT);
$resultSet = $this->selectWith($select);
var_dump($resultSet);
return $resultSet->toArray();
}
该语句正在构建,因为它应该是:
public 'queryString' => string 'SELECT `course`.*, `studyprogram`.`studyprogram_title` AS `studyprogram_title` FROM `course` LEFT JOIN `studyprogram` ON `studyprogram`.`studyprogram_id` = `course`.`studyprogram_id` WHERE `course_active` = :where1' (length=214)
在获取结果时,它忽略了“studyprogram_title”列,我猜是因为给定的结果集(带有绑定的 CourseEntity)
有没有办法在不将其添加到 CourseEntity 的情况下显示 studyprogram_title?它不是它的一部分,所以我猜如果我在那里添加它会很脏。