1: <?php
2: namespace TIC\DormBundle\Hydration;
3:
4: use Doctrine\ORM\Internal\Hydration\ArrayHydrator;
5:
6: /**
7: * Récupération des résultats groupés par les valeurs uniques de la 1ère colonne (en index)
8: *
9: * Exemple:
10: * > SELECT a, b, c FROM t
11: * < array(
12: * a1 => array('a' => a1, 'b' => b1, 'c' => c1)
13: * a2 => array('a' => a2, 'b' => b2, 'c' => c2)
14: * ...
15: * )
16: */
17: class KeyhashHydrator extends ArrayHydrator
18: {
19:
20: /**
21: * Hydrates all rows from the current statement instance at once.
22: *
23: * @return mixed[]
24: */
25: protected function hydrateAllData(): array
26: {
27: $result = array();
28:
29: foreach (parent::hydrateAllData() as $data) {
30: $key = \reset($data);
31: if ($key === null) $key = '[_NULL_]';
32: elseif ($key === '') $key = '[_EMPTY_]';
33:
34: $result[ $key ] = $data;
35: }
36:
37: return $result;
38: }
39:
40: }
41: