Add Document and Bibliography
This commit is contained in:
44
src/Repository/BibliographyRepository.php
Normal file
44
src/Repository/BibliographyRepository.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Bibliography;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Bibliography>
|
||||
*/
|
||||
class BibliographyRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Bibliography::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Bibliography[]
|
||||
*/
|
||||
public function findAllByNotConserved(int $notConserId): array
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->getEntityManager());
|
||||
$rsm->addRootEntityFromClassMetadata('App\Entity\Bibliography', 'b');
|
||||
$query = $this->getEntityManager()->createNativeQuery(
|
||||
'SELECT
|
||||
id,
|
||||
citazione,
|
||||
riferimento,
|
||||
pagine
|
||||
FROM bibliografia b
|
||||
JOIN bibliografia_non_conser
|
||||
ON id_bibliografia = b.id
|
||||
WHERE id_non_conser = :id',
|
||||
$rsm
|
||||
);
|
||||
|
||||
$query->setParameter('id', $notConserId);
|
||||
|
||||
return $query->getResult();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Repository;
|
||||
use App\Entity\Document;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Document>
|
||||
@@ -16,6 +17,34 @@ class DocumentRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, Document::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Document[] Returns an array of Document objects
|
||||
*/
|
||||
public function findBySite(int $siteId): array
|
||||
{
|
||||
$rsm = new ResultSetMappingBuilder($this->getEntityManager());
|
||||
$rsm->addRootEntityFromClassMetadata('App\Entity\Document', 'd');
|
||||
$query = $this->getEntityManager()->createNativeQuery(
|
||||
'SELECT
|
||||
id,
|
||||
titolo,
|
||||
filename,
|
||||
descrizione,
|
||||
autori,
|
||||
tipo
|
||||
FROM documento d
|
||||
JOIN sito_documento
|
||||
ON id_documento = d.id
|
||||
WHERE id_sito = :id
|
||||
',
|
||||
$rsm
|
||||
);
|
||||
|
||||
$query->setParameter('id', $siteId);
|
||||
|
||||
return $query->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Document[] Returns an array of Document objects
|
||||
// */
|
||||
|
||||
Reference in New Issue
Block a user