我在存储库中有这段代码:
public function getNotAssignedBy($speciality, $diploma)
{
$qb = $this->createQueryBuilder('j')
->select('DISTINCT(j.id) id', 'j.firstName', 'j.lastName', 'j.dateBirth', 'j.sex')
->leftJoin('j.qualifications', 'q')
;
if ($speciality) {
$qb->andWhere('q.speciality = :speciality_id')->setParameter('speciality_id', $speciality);
}
if ($diploma) {
$qb->andWhere('q.diploma = :diploma_id')->setParameter('diploma_id', $diploma);
}
$result = $qb->getQuery()->getResult();
return $result;
}
如何才能获得另一个实体中不存在id的行?
任何帮助。感谢
答案 0 :(得分:18)
你可以用这样的东西来实现它:
echo "<form action='file-here/process.php' method='post' enctype='multipart/form-data' target='upload_target' id='form-reset'>";
echo "<iframe id='upload_target' name='upload_target' ></iframe>";
echo "<select name='id' id='form-option' class='test-only'>";
echo '<option selected="selected">' .'Choose a User'. '</option>';
foreach ($registeredUsers as $key => $value) {
$registered = JFactory::getUser($value);
echo '<option value="'.$registered->id.'">'.$registered->name.'</option>';
}
echo "</select>";
echo "<input name='uploadedfile' type='file' id='custom-file-input' class='test-only' /><br/>";
echo '<input type="submit" name="submit" value="Upload" id="custom-submit-input" >';
echo "</form>";
希望这个帮助
答案 1 :(得分:0)
由于我无法评论,所以我将发布 greg0ire 解决方案的固定版本
$sub = $this->_em->createQueryBuilder();// _em stands for entity manager here. While $qb may use repositories createQueryBuilder() which requires alias
$sub->select("t");
$sub->from("AnotherEntity","t");
$sub->andWhere('t.user = j.id');
// Your query builder:
$qb->andWhere($qb->expr()->not($qb->expr()->exists($sub->getDQL())));