1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
<?php
namespace itvtube\IienBundle\Entity;
class VideoRepository extends Video
{
public function findMostViewed ($limit = 5) {
$qb = $this ->createQueryBuilder('Video')
->orderBy('Video.vues','DESC')
->setMaxResults($limit)
;
$results = $qb->getQuery()->getResult();
return $results ;
}
public function findLastProj () {
$qb = $this ->createQueryBuilder('Proj')
->orderBy('Proj.id','DESC')
->setMaxResults(1)
;
$results = $qb->getQuery()->getResult();
return $results ;
}
public function findFavoris ($iien_id) {
$qb = $this ->createQueryBuilder('Favori')
->where('Favori.iien = $iien_id')
;
$results = $qb->getQuery()->getResult();
return $results ;
}
public function findMostFavored ($limit = 5) {
$qb = $this ->createQueryBuilder('Video')
->orderBy($qb->expr()->count('Video.favoris'),'DESC')
->setMaxResults($limit)
;
$results = $qb->getQuery()->getResult();
return $results ;
}
public function getArbo () {
$qb = $this ->createQueryBuilder('Annee')
->orderBy('Proj.id','DESC')
;
$annees = $qb->getQuery()->getResult();
foreach ($annees as $annee) {
$annee_id = $annee -> getId();
$annee_label = $annee -> getLabel()
$arbo[] = array($annee_label, $annee_id, array());
$qb = $this ->createQueryBuilder('Proj')
->where('Proj.annee = $annee_id')
->orderBy('Proj.id','DESC')
;
$projs = $qb->getQuery()->getResult();
$index = count($histo) - 1;
foreach ($projs as $proj) {
$proj_id = $proj -> getId();
$proj_nom = $proj -> getNom()
$arbo[$index][2][] = array($proj_nom, $proj_id);
}
}
return $arbo ;
}
public function getAnneeVideos ($annee_id) {
$qb = $this -> createQueryBuilder('Proj')
-> where('Proj.annee = $annee_id')
-> orderBy('Proj.id','ASC')
;
$projs = $qb->getQuery()->getResult();
foreach ($projs as $proj) {
$proj_id = $proj -> getId();
$qb = $this -> createQueryBuilder('Video')
-> where('Video.proj = $proj_id')
-> orderBy('Video.id','ASC')
;
$videos = $qb -> getQuery() -> getResult();
foreach ($videos as $video) {
$results[] = $video
}
}
return $results ;
}
public function getProjVideos ($proj_id) {
$qb = $this -> createQueryBuilder('Video')
-> where('Video.proj = $proj_id')
-> orderBy('Video.id','ASC')
;
$videos = $qb -> getQuery() -> getResult();
foreach ($videos as $video) {
$results[] = $video
}
return $results ;
}
public function getSearchVideos ($textinput) {
return $results ;
}
} |
Partager