79 lines
2.5 KiB
PHP
79 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Stats;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<Stats>
|
|
*/
|
|
class StatsRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Stats::class);
|
|
}
|
|
|
|
/**
|
|
* Find all cities without using problematic columns
|
|
*
|
|
* @return Stats[] Returns an array of Stats objects
|
|
*/
|
|
public function findAllCitiesWithoutLabourage(): array
|
|
{
|
|
// Use native SQL to avoid ORM mapping issues with missing columns
|
|
$conn = $this->getEntityManager()->getConnection();
|
|
$sql = '
|
|
SELECT id, zone, completion_percent, places_count, avec_horaires,
|
|
avec_adresse, avec_site, avec_accessibilite, avec_note,
|
|
name, population, siren, code_epci, codes_postaux,
|
|
date_created, date_modified, avec_siret, avec_name,
|
|
osm_data_date_min, osm_data_date_avg, osm_data_date_max,
|
|
budget_annuel, lat, lon
|
|
FROM stats
|
|
WHERE zone != :global_zone
|
|
';
|
|
$stmt = $conn->prepare($sql);
|
|
$resultSet = $stmt->executeQuery(['global_zone' => '00000']);
|
|
|
|
$results = $resultSet->fetchAllAssociative();
|
|
|
|
// Get existing Stats entities by ID
|
|
$statsEntities = [];
|
|
foreach ($results as $row) {
|
|
$stats = $this->find($row['id']);
|
|
if ($stats) {
|
|
$statsEntities[] = $stats;
|
|
}
|
|
}
|
|
|
|
return $statsEntities;
|
|
}
|
|
|
|
// /**
|
|
// * @return Stats[] Returns an array of Stats objects
|
|
// */
|
|
// public function findByExampleField($value): array
|
|
// {
|
|
// return $this->createQueryBuilder('s')
|
|
// ->andWhere('s.exampleField = :val')
|
|
// ->setParameter('val', $value)
|
|
// ->orderBy('s.id', 'ASC')
|
|
// ->setMaxResults(10)
|
|
// ->getQuery()
|
|
// ->getResult()
|
|
// ;
|
|
// }
|
|
|
|
// public function findOneBySomeField($value): ?Stats
|
|
// {
|
|
// return $this->createQueryBuilder('s')
|
|
// ->andWhere('s.exampleField = :val')
|
|
// ->setParameter('val', $value)
|
|
// ->getQuery()
|
|
// ->getOneOrNullResult()
|
|
// ;
|
|
// }
|
|
}
|