I have the tables:
Operário(id,identidade(string));
Intervenção (data(date), hora(time), duracao(integer));
Avaria (data(date), descricao(string), impedimento(boolean));
Prevista (contagem(integer), duracao(integer), fazer(string), tempo(integer), ficha(string));
And I have the repository done.
class IntervencaoRepository extends EntityRepository {
public function getRecentIntervencao($number = 30) {
$dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ORDER BY b.created DESC";
$query = $this->getEntityManager()->createQuery($dql);
$query->setMaxResults($number);
return $query->getResult();
}
public function getRecentIntervencaoArray($number = 30) {
$dql = "SELECT b, e, r, p FROM Bug b JOIN b.engineer e ".
"JOIN b.reporter r JOIN b.products p ORDER BY b.created DESC";
$query = $this->getEntityManager()->createQuery($dql);
$query->setMaxResults($number);
return $query->getArrayResult();
}
public function getUsersIntervencao($userId, $number = 15) {
$dql = "SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ".
"WHERE b.status = 'OPEN' AND e.id = ?1 OR r.id = ?1 ORDER BY b.created DESC";
return $this->getEntityManager()->createQuery($dql) ->setParameter(1, $userId) ->setMaxResults($number) ->getResult();
}
public function getOpenIntervencaoByProduct() {
$dql = "SELECT p.id, p.name, count(b.id) AS openBugs FROM Bug b ".
"JOIN b.products p WHERE b.status = 'OPEN' GROUP BY p.id";
return $this->getEntityManager()->createQuery($dql)->getScalarResult();
}
}
And I wanted in% w /% to call parameters / variables.