getPreparedQuery($sql) ->setParams(['user_id' => $userId]) ->query($this->getCollection($this->getHydratorForUserBadge())) ; } private function getHydratorForUserBadge() { return (new HydratorSingleObject()) ->mapObjectTo('afup_badge', 'afup_personnes_physiques_badge', 'setBadge') ; } /** * @param SerializerFactoryInterface $serializerFactory * @param array $options * * @return Metadata * * @throws \CCMBenchmark\Ting\Exception */ public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) { $metadata = new Metadata($serializerFactory); $metadata->setEntity(UserBadge::class); $metadata->setConnectionName('main'); $metadata->setDatabase($options['database']); $metadata->setTable('afup_personnes_physiques_badge'); $metadata ->addField([ 'columnName' => 'afup_personne_physique_id', 'fieldName' => 'userId', 'primary' => true, 'type' => 'int' ]) ->addField([ 'columnName' => 'badge_id', 'fieldName' => 'badgeId', 'primary' => true, 'type' => 'int' ]) ->addField([ 'columnName' => 'issued_at', 'fieldName' => 'issuedAt', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => false] ] ]) ; return $metadata; } }