Skip to content
Extraits de code Groupes Projets
Valider c3b49c7b rédigé par Okhin's avatar Okhin
Parcourir les fichiers

A better SQL command return ONLY the bigger ordered item by user_id and day

parent 43da7c56
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!92Preprod,!91A better SQL command return ONLY the bigger ordered item by user_id and day
......@@ -131,8 +131,8 @@ EOF;
// Those are the parents ID, grouped by day.
$parents = $this->connection->executeQuery(
"select id from contreparties WHERE user_id = :user_id group by user_id, dayofyear(datec) order by field(quoi, 'piplome', 'pibag', 'pishirt', 'hoodie')",
[ 'user_id' => $user_id]
"SELECT id FROM contreparties c JOIN (SELECT MAX(FIELD(quoi, 'piplome', 'pibag', 'pishirt', 'hoodie')) m FROM contreparties GROUP BY user_id, dayofyear(datec)) AS m WHERE FIELD(c.quoi, 'piplome', 'pibag', 'pishirt', 'hoodie') = m.m AND user_id = :user_id",
[ 'user_id' => $user_id ]
)->fetchAll(\PDO::FETCH_COLUMN);
foreach ($parents as $parent) {
......
......@@ -15,7 +15,7 @@ class CounterpartHandlerTest extends FunctionalTest
{
$this->container['command_handler']->handle(new AdminUpdateParentCommand());
$target = $this->container['counterpart_finder']->findById(4);
$this->assertSame((int) $target['parent'], 2);
$this->assertSame((int) $target['parent'], 4);
}
public function testCounterpartDelete()
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter