我尝试了以下内容:
$subQuery = $this->createQueryBuilder('teachingEvent')->select('teachingEvent.id')
->leftJoin('teachingEvent.timeTableEntry', 'timeTableEntry')
->leftJoin('timeTableEntry.course', 'course')
->where('course.school = :school' )
->andWhere('teachingEvent.date >= :fromDate')
->andWhere('teachingEvent.date <= :toDate')
->setParameters(array(':fromDate' => $from, ':toDate' => $to, ':school' => $school))
->getDQL();
$query = $this->createQueryBuilder('teachingEvent')
->update()
->set('teachingEvent.schoolFreeDate', ':schoolFreeDate')
->where('teachingEvent.id IN ' . $subQuery)
->getQuery();
return $query->getResult();
当我转出子查询时,我得到了这个:
&#34; SELECT teachingEvent.id FROM AppBundle \ Entity \ TeachingEvent teachingEvent LEFT JOIN teachingEvent.timeTableEntry timeTableEntry LEFT JOIN timeTableEntry.course course WHERE course.school =:school AND teachingEvent.date&gt; =:fromDate AND teachingEvent.date &lt; =:toDate
对我来说,似乎应该现在可以正常工作 - 但我收到以下错误消息
[语法错误]第0行,第136栏:错误:预期文字,得到&#39; teachingEvent&#39;
如果有人能找到错误会很好。
谢谢你!
新年快乐;)!
答案 0 :(得分:1)
您也可以首先从第一个查询构建器获取对象,然后执行所需的更新
$sql="SELECT * FROM vinay;";
$result=mysqli_query($conn,$sql);
$resultCheck=mysqli_num_rows($result);
if($resultCheck>o)
{
while($row=mysqli_fetch_assoc($result))
{
echo $row[0];
}
}