->addScalarResult('longitude', 'longitude', 'float')
->addScalarResult('indoor', 'indoor', 'boolean')
->addScalarResult('count', 'count', 'integer')
- ->addScalarResult('updated', 'updated', 'datetime');
+ ->addScalarResult('updated', 'updated', 'datetime_immutable');
//Get result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('begin', $period->getStartDate())
->setParameter('end', $period->getEndDate())
l.latitude,
l.longitude,
l.indoor,
- GREATEST(l.created, l.updated, COALESCE(s.created, 0), COALESCE(s.updated, 0)) AS modified,
+ GREATEST(l.created, l.updated, COALESCE(s.created, '1970-01-01'), COALESCE(s.updated, '1970-01-01')) AS modified,
l.zipcode,
COUNT(s.id) AS count,
COUNT(IF(s.date BETWEEN :begin AND :end, s.id, NULL)) AS pcount
->addScalarResult('indoors', 'indoors', 'string')
//XXX: is a string because of \n separator
->addScalarResult('counts', 'counts', 'string')
- ->addScalarResult('modified', 'modified', 'datetime')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
->addIndexByScalar('city');
//Get result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('begin', $period->getStartDate())
->setParameter('end', $period->getEndDate())
->addScalarResult('city', 'city', 'string')
->addScalarResult('latitude', 'latitude', 'float')
->addScalarResult('longitude', 'longitude', 'float')
- ->addScalarResult('updated', 'updated', 'datetime')
+ ->addScalarResult('updated', 'updated', 'datetime_immutable')
->addIndexByScalar('city');
//Get result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('latitude', $latitude)
->setParameter('longitude', $longitude)
a.longitude,
a.created,
a.updated,
- MAX(GREATEST(a.modified, COALESCE(s.created, 0), COALESCE(s.updated, 0))) AS modified,
+ MAX(GREATEST(a.modified, COALESCE(s.created, '1970-01-01'), COALESCE(s.updated, '1970-01-01'))) AS modified,
COUNT(s.id) AS count
FROM (
SELECT
->addScalarResult('title', 'title', 'string')
->addScalarResult('latitude', 'latitude', 'float')
->addScalarResult('longitude', 'longitude', 'float')
- ->addScalarResult('created', 'created', 'datetime')
- ->addScalarResult('updated', 'updated', 'datetime')
- ->addScalarResult('modified', 'modified', 'datetime')
+ ->addScalarResult('created', 'created', 'datetime_immutable')
+ ->addScalarResult('updated', 'updated', 'datetime_immutable')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
->addScalarResult('count', 'count', 'integer');
//Get result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('begin', $period->getStartDate())
->setParameter('end', $period->getEndDate())
a.longitude,
a.created,
a.updated,
- MAX(GREATEST(a.modified, COALESCE(s3.created, 0), COALESCE(s3.updated, 0))) AS modified,
+ MAX(GREATEST(a.modified, COALESCE(s3.created, '1970-01-01'), COALESCE(s3.updated, '1970-01-01'))) AS modified,
a.pcount,
COUNT(s3.id) AS tcount
FROM (
b.longitude,
b.created,
b.updated,
- MAX(GREATEST(b.modified, COALESCE(s2.created, 0), COALESCE(s2.updated, 0))) AS modified,
+ MAX(GREATEST(b.modified, COALESCE(s2.created, '1970-01-01'), COALESCE(s2.updated, '1970-01-01'))) AS modified,
COUNT(s2.id) AS pcount
FROM (
SELECT
->addScalarResult('city', 'city', 'string')
->addScalarResult('latitude', 'latitude', 'float')
->addScalarResult('longitude', 'longitude', 'float')
- ->addScalarResult('created', 'created', 'datetime')
- ->addScalarResult('updated', 'updated', 'datetime')
- ->addScalarResult('modified', 'modified', 'datetime')
+ ->addScalarResult('created', 'created', 'datetime_immutable')
+ ->addScalarResult('updated', 'updated', 'datetime_immutable')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
->addScalarResult('pcount', 'pcount', 'integer')
->addScalarResult('tcount', 'tcount', 'integer');
//Get result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('begin', $period->getStartDate())
->setParameter('end', $period->getEndDate())
->addScalarResult('longitude', 'longitude', 'float')
->addScalarResult('indoor', 'indoor', 'boolean')
->addScalarResult('zipcode', 'zipcode', 'string')
- ->addScalarResult('modified', 'modified', 'datetime')
+ ->addScalarResult('modified', 'modified', 'datetime_immutable')
->addScalarResult('city_id', 'city_id', 'integer')
->addScalarResult('city_latitude', 'city_latitude', 'float')
->addScalarResult('city_longitude', 'city_longitude', 'float')
->addIndexByScalar('id');
//Get result
- $result = $this->_em
+ $result = $this->manager
->createNativeQuery($req, $rsm)
->setParameter('id', $id)
->getOneOrNullResult();
*/
public function findComplementBySessionId(int $id): array {
//Fetch complement locations
- $ret = $this->getEntityManager()
- ->createQuery('SELECT l.id, l.title FROM Rapsys\AirBundle\Entity\Session s LEFT JOIN Rapsys\AirBundle\Entity\Session s2 WITH s2.id != s.id AND s2.slot = s.slot AND s2.date = s.date LEFT JOIN Rapsys\AirBundle\Entity\Location l WITH l.id != s.location AND (l.id != s2.location OR s2.location IS NULL) WHERE s.id = :sid GROUP BY l.id ORDER BY l.id')
- ->setParameter('sid', $id)
- ->getArrayResult();
-
- //TODO: try to improve with:
- #->addIndexByScalar('city');
-
- //Rekey array
- $ret = array_column($ret, 'id', 'title');
-
- return $ret;
+ return array_column(
+ $this->getEntityManager()
+ #->createQuery('SELECT l.id, l.title FROM Rapsys\AirBundle\Entity\Location l JOIN Rapsys\AirBundle\Entity\Session s WITH s.id = :sid LEFT JOIN Rapsys\AirBundle\Entity\Session s2 WITH s2.id != s.id AND s2.slot = s.slot AND s2.date = s.date WHERE l.id != s.location AND s2.location IS NULL GROUP BY l.id ORDER BY l.id')
+ ->createQuery('SELECT l.id, l.title FROM Rapsys\AirBundle\Entity\Session s LEFT JOIN Rapsys\AirBundle\Entity\Session s2 WITH s2.id != s.id AND s2.slot = s.slot AND s2.date = s.date LEFT JOIN Rapsys\AirBundle\Entity\Location l WITH l.id != s.location AND (l.id != s2.location OR s2.location IS NULL) WHERE s.id = :sid GROUP BY l.id ORDER BY l.id')
+ ->setParameter('sid', $id)
+ ->getArrayResult(),
+ 'id',
+ 'title'
+ );
}
/**
->addFieldResult('l', 'title', 'title');
//Send result
- return $this->_em
+ return $this->manager
->createNativeQuery($req, $rsm)
->setParameter('id', $userId)
->getResult();