X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/airbundle/blobdiff_plain/1be898ed564b18e6ac635d4d605efd7a388991b3..bda45c555c96461e7a0e9533360c2d79fa805438:/Repository/SessionRepository.php diff --git a/Repository/SessionRepository.php b/Repository/SessionRepository.php index c310b54..030dd35 100644 --- a/Repository/SessionRepository.php +++ b/Repository/SessionRepository.php @@ -141,9 +141,9 @@ SQL; $rsm->addScalarResult('id', 'id', 'integer') ->addScalarResult('date', 'date', 'date') ->addScalarResult('begin', 'begin', 'time') - ->addScalarResult('start', 'start', 'datetime') + ->addScalarResult('start', 'start', 'datetime_immutable') ->addScalarResult('length', 'length', 'time') - ->addScalarResult('stop', 'stop', 'datetime') + ->addScalarResult('stop', 'stop', 'datetime_immutable') ->addScalarResult('rainfall', 'rainfall', 'float') ->addScalarResult('rainrisk', 'rainrisk', 'float') ->addScalarResult('realfeel', 'realfeel', 'float') @@ -152,9 +152,9 @@ SQL; ->addScalarResult('temperature', 'temperature', 'float') ->addScalarResult('temperaturemin', 'temperaturemin', 'float') ->addScalarResult('temperaturemax', 'temperaturemax', 'float') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('created', 'created', 'datetime') - ->addScalarResult('updated', 'updated', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('created', 'created', 'datetime_immutable') + ->addScalarResult('updated', 'updated', 'datetime_immutable') ->addScalarResult('l_id', 'l_id', 'integer') ->addScalarResult('l_title', 'l_title', 'string') ->addScalarResult('l_description', 'l_description', 'string') @@ -164,11 +164,11 @@ SQL; ->addScalarResult('l_latitude', 'l_latitude', 'float') ->addScalarResult('l_longitude', 'l_longitude', 'float') ->addScalarResult('l_indoor', 'l_indoor', 'boolean') - ->addScalarResult('l_updated', 'l_updated', 'datetime') + ->addScalarResult('l_updated', 'l_updated', 'datetime_immutable') ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_id', 'ad_id', 'integer') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') @@ -183,7 +183,7 @@ SQL; ->addScalarResult('p_profile', 'p_profile', 'text') ->addScalarResult('p_rate', 'p_rate', 'integer') ->addScalarResult('p_hat', 'p_hat', 'boolean') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('modified', 'modified', 'datetime_immutable') //XXX: is a string because of \n separator ->addScalarResult('sa_id', 'sa_id', 'string') //XXX: is a string because of \n separator @@ -201,7 +201,7 @@ SQL; ->addIndexByScalar('id'); //Set result - $result = $this->_em + $result = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $id) ->getOneOrNullResult(); @@ -461,7 +461,7 @@ SQL; //XXX: check that latitude and longitude have not be swapped !!! //XXX: latitude ~= 48.x longitude ~= 2.x $locationIds = array_keys( - $this->_em + $this->manager ->createNativeQuery($req, $rsm) ->setParameter('latitude', $latitude) ->setParameter('longitude', $longitude) @@ -507,7 +507,7 @@ SQL; //Set location ids $locationIds = array_keys( - $this->_em + $this->manager ->createNativeQuery($req, $rsm) ->setParameter('id', $userId) ->getArrayResult() @@ -590,10 +590,10 @@ SQL; ->addScalarResult('rainfall', 'rainfall', 'float') ->addScalarResult('realfeel', 'realfeel', 'float') ->addScalarResult('temperature', 'temperature', 'float') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('start', 'start', 'datetime') - ->addScalarResult('stop', 'stop', 'datetime') - ->addScalarResult('modified', 'modified', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('start', 'start', 'datetime_immutable') + ->addScalarResult('stop', 'stop', 'datetime_immutable') + ->addScalarResult('modified', 'modified', 'datetime_immutable') ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('l_id', 'l_id', 'integer') @@ -605,7 +605,7 @@ SQL; ->addScalarResult('l_longitude', 'l_longitude', 'float') ->addScalarResult('l_indoor', 'l_indoor', 'boolean') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_id', 'ad_id', 'string') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') @@ -627,7 +627,7 @@ SQL; ->addIndexByScalar('id'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()); @@ -965,7 +965,7 @@ SQL; //With user dance if ( - $userDances = $this->_em + $userDances = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('uid', $userId) ->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN) @@ -995,7 +995,7 @@ SQL; //With user subscription if ( - $userSubscriptions = $this->_em + $userSubscriptions = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('uid', $userId) ->getResult(AbstractQuery::HYDRATE_SCALAR_COLUMN) @@ -1059,10 +1059,10 @@ SQL; $rsm ->addScalarResult('id', 'id', 'integer') ->addScalarResult('date', 'date', 'date') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('modified', 'modified', 'datetime') - ->addScalarResult('start', 'start', 'datetime') - ->addScalarResult('stop', 'stop', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('modified', 'modified', 'datetime_immutable') + ->addScalarResult('start', 'start', 'datetime_immutable') + ->addScalarResult('stop', 'stop', 'datetime_immutable') ->addScalarResult('l_id', 'l_id', 'integer') ->addScalarResult('l_address', 'l_address', 'string') ->addScalarResult('l_zipcode', 'l_zipcode', 'string') @@ -1074,7 +1074,7 @@ SQL; ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') ->addScalarResult('au_id', 'au_id', 'integer') @@ -1094,7 +1094,7 @@ SQL; //Return sessions //TODO: XXX: finish here - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->setParameter('dids', $userDances) ->setParameter('uids', $userSubscriptions) @@ -1186,10 +1186,10 @@ SQL; //addScalarResult($sqlColName, $resColName, $type = 'string'); $rsm->addScalarResult('id', 'id', 'integer') ->addScalarResult('date', 'date', 'date') - ->addScalarResult('locked', 'locked', 'datetime') - ->addScalarResult('updated', 'updated', 'datetime') - ->addScalarResult('start', 'start', 'datetime') - ->addScalarResult('stop', 'stop', 'datetime') + ->addScalarResult('locked', 'locked', 'datetime_immutable') + ->addScalarResult('updated', 'updated', 'datetime_immutable') + ->addScalarResult('start', 'start', 'datetime_immutable') + ->addScalarResult('stop', 'stop', 'datetime_immutable') ->addScalarResult('l_id', 'l_id', 'integer') ->addScalarResult('l_address', 'l_address', 'string') ->addScalarResult('l_zipcode', 'l_zipcode', 'string') @@ -1201,7 +1201,7 @@ SQL; ->addScalarResult('t_id', 't_id', 'integer') ->addScalarResult('t_title', 't_title', 'string') ->addScalarResult('a_id', 'a_id', 'integer') - ->addScalarResult('a_canceled', 'a_canceled', 'datetime') + ->addScalarResult('a_canceled', 'a_canceled', 'datetime_immutable') ->addScalarResult('ad_name', 'ad_name', 'string') ->addScalarResult('ad_type', 'ad_type', 'string') ->addScalarResult('au_id', 'au_id', 'integer') @@ -1220,7 +1220,7 @@ SQL; ->addIndexByScalar('id'); //Fetch result - $res = $this->_em + $res = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('begin', $period->getStartDate()) ->setParameter('end', $period->getEndDate()); @@ -1273,7 +1273,7 @@ SQL; ->addIndexBy('s', 'id'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -1322,7 +1322,7 @@ SQL; ->addIndexBy('s', 'id'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -1364,7 +1364,7 @@ SQL; ->addIndexBy('s', 'id'); //Send result - return $this->_em + return $this->manager ->createNativeQuery($req, $rsm) ->getResult(); } @@ -1518,7 +1518,7 @@ SQL; //Get result //XXX: setting limit in subqueries is required to prevent mariadb optimisation - $applications = $this->_em + $applications = $this->manager ->createNativeQuery($req, $rsm) ->setParameter('sid', $id) ->getResult(); @@ -1536,7 +1536,7 @@ SQL; //Update application updated field //XXX: updated field is not modified for user with bad behaviour as application is not retrieved until delay is reached - $this->_em->getConnection()->executeUpdate($upreq, ['id' => $application->getId(), 'score' => $application->getScore()], ['id' => Types::INTEGER, 'score' => Types::FLOAT]); + $this->manager->getConnection()->executeUpdate($upreq, ['id' => $application->getId(), 'score' => $application->getScore()], ['id' => Types::INTEGER, 'score' => Types::FLOAT]); } //Return best ranked application @@ -1550,7 +1550,7 @@ SQL; */ function rekey(): bool { //Get connection - $cnx = $this->_em->getConnection(); + $cnx = $this->manager->getConnection(); //Set the request $req = <<addIndexByScalar('id'); //Fetch result - $rnq = $this->_em->createNativeQuery($req, $rsm); + $rnq = $this->manager->createNativeQuery($req, $rsm); //Get result set $res = $rnq->getResult();