Emits the after select event

@param RecordList $data
@param EntityCollection $entities

@return \League\Event\EventInterface|string
555130
public function triggerAfterSelect($data, EntityCollection $entities)
    {
        $event = new \Slick\Orm\Event\Select(
            null,
            [
                'data' => $data,
                'entityCollection' => $entities
            ]
        );
        $event->setAction(\Slick\Orm\Event\Select::ACTION_AFTER_SELECT);
        return Orm::getEmitter($this->getEntityClassName())
            ->emit($event);
    }
724397
public static function didFinishIndexingRecords(array $records, databox $databox)
    {
        $connection = $databox->get_connection();
        $sql = "UPDATE record SET jeton = (jeton & ~ :flag) WHERE record_id IN (:record_ids)";
        self::executeFlagQuery($connection, $sql, Flag::TO_INDEX | Flag::INDEXING, $records);
    }
943935
public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options)
    {
        if (!$this->config('status')) {
            return true;
        }

        // as we don't know entity's ID on beforeSave, we must delay values storage;
        // all this occurs inside a transaction so we are safe
        if (!empty($this->_cache['createValues'])) {
            foreach ($this->_cache['createValues'] as $valueEntity) {
                $valueEntity->set('entity_id', $this->_toolbox->getEntityId($entity));
                $valueEntity->unsetProperty('id');
                TableRegistry::get('Eav.EavValues')->save($valueEntity);
            }
            $this->_cache['createValues'] = [];
        }

        foreach ($this->_attributesForEntity($entity) as $attr) {
            $field = $this->_prepareMockField($entity, $attr);
            $field->afterSave();
        }

        if ($this->config('cacheMap')) {
            $this->updateEavCache($entity);
        }

        return true;
    }
738253
public function beforeSave(Event $event, Entity $entity) {
		if (isset($entity['ext'])) {
			$entity['ext'] = mb_strtolower($entity['ext']);
		}
		if (isset($entity['name'])) {
			$entity['name'] = ucwords($entity['name']);
		}
	}
878560
protected function _afterRegister(EntityInterface $entity, $options) {
		if ($entity) {
			if ($options['emailVerification'] === true) {
				$this->sendVerificationEmail($entity, [
					'to' => $entity->get($this->_field('email'))
				]);
			}
		}

		return $entity;
	}
458147
public function serialize(EntityContract $entity, Collection $select = null)
    {
        $bag = parent::serialize($entity, $select);

        $bag->set('readable', $bag->get('street').' '.$bag->get('city').' ('.$bag->get('zip_code').') '.$bag->get('province'));

        return $bag;
    }
688762
@Override
    protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> relations)
    {
        String tableName = HBaseUtils.getHTableName(entityMetadata.getSchema(), entityMetadata.getTableName());
        try
        {
            handler.writeData(tableName, entityMetadata, entity, id, relations, showQuery);
        }
        catch (IOException e)
        {
            throw new PersistenceException(e);
        }
    }
457852
public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options) {
		if ($this->_config['on'] !== 'afterSave') {
			return;
		}

		if (!$entity->isDirty($this->getConfig('field'))) {
			return;
		}

		$value = $entity->get($this->getConfig('field'));
		if (!$value && !$this->getCurrent($entity)) {
			// This should be caught with a validation rule as this is not normal behavior
			throw new LogicException();
		}

		$this->removeFromOthers($entity);
	}
500391
public function process($field, EntityInterface $data, array $options = [])
    {
        $this->setContext($data);

        $value = $this->fieldValue($data, $field);
        $options += ['formatter' => null];

        if ($options['formatter'] === 'element') {
            $context = $this->getContext();

            return $this->_View->element($options['element'], compact('context', 'field', 'value', 'options'));
        }

        if ($options['formatter'] === 'relation') {
            $relation = $this->relation($field);
            if ($relation) {
                return $relation['output'];
            }
        }

        if (is_callable($options['formatter'])) {
            return $options['formatter']($field, $value, $this->getContext(), $options, $this->getView());
        }

        $value = $this->introspect($field, $value, $options);

        return $value;
    }
590379
public function afterSave(Event $event, EntityInterface $entity)
    {
        $property = $this->versionAssociation()->getProperty();
        $entity->unsetProperty($property);
    }
1223725
protected function afterSave(EntityInterface $entity): void
    {
        $argv = compact('entity');
        $argv = $this->getEventManager()->prepareArgs($argv);

        $this->getEventManager()->trigger("{$this->event_prefix}_save_after", $this, $argv);
        if ($this->entity_event_prefix) {
            $this->getEventManager()->trigger("{$this->entity_event_prefix}_save_after", $this, $argv);
        }
    }
1259446
private function processPasteAfter(CollectionInterface $models, ModelIdInterface $after = null)
    {
        if ($after && $models->count() && $after->getId()) {
            $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment());

            $this->pasteAfter($this->modelCollector->getModel($after), $models, $manualSorting);

            $this->triggerPostPasteModel($models);
            $this->clearModelCollection($models);
        }
    }
511037
protected function triggerAfterSave(
        Save $saveEvent, EntityInterface $entity
    ) {
        $afterSave = clone $saveEvent;
        $action = $afterSave->getName() == Save::ACTION_BEFORE_INSERT
            ? Save::ACTION_AFTER_INSERT
            : Save::ACTION_AFTER_UPDATE;

        $afterSave->setEntity($entity)->setAction($action);
        return Orm::getEmitter($this->getEntityClassName())
            ->emit($afterSave);
    }
1134986
public function setCalendarEventData(array $data = [], ?EntityInterface $calendar = null): array
    {
        $result = [
            'CalendarEvents' => [],
        ];

        $result['CalendarEvents'] = $data;
        if (!empty($data['recurrence'])) {
            $recurrence = $this->setRRuleConfiguration($data['recurrence']);
            $result['CalendarEvents']['is_recurring'] = true;
            $result['CalendarEvents']['recurrence'] = $recurrence;
        }

        if (!empty($data['attendees_ids'])) {
            $result['calendar_attendees']['_ids'] = $data['attendees_ids'];
            unset($result['CalendarEvents']['attendees_ids']);
        }

        if (empty($data['title']) && $calendar instanceof EntityInterface) {
            $result['CalendarEvents']['title'] = $this->setEventTitle($data, $calendar);
        }

        return $result;
    }
445279
public function getExportRecords($data)
    {
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');

        //var_dump($data);

        $gameId         = $data['gameid'];

        $lastName       = $data['lastname'];
        $lastNameInput  = $data['lastname-input'];

        $firstName      = $data['firstname'];
        $firstNameInput     = $data['firstname-input'];

        $sexe           = $data['sexe'];

        $memberId       = $data['memberid'];
        $memberIdInput  = $data['memberid-input'];

        $email          = $data['email'];
        $emailInput     = $data['email-input'];

        $zipcode        = $data['zipcode'];
        $zipcodeInput   = $data['zipcode-input'];

        $birthdate      = $data['birthdate'];
        $dobStartIni    = $data['birthdate-start'];
        $dobEndIni      = $data['birthdate-end'];
        $dobEqualIni    = $data['birthdate-equal'];
        $dobStart       = \DateTime::createFromFormat('d/m/Y', $dobStartIni);
        $dobEnd         = \DateTime::createFromFormat('d/m/Y', $dobEndIni);
        $dobEqual       = \DateTime::createFromFormat('d/m/Y', $dobEqualIni);

        $hobbies        = $data['prizeCategory'];

        $optin          = $data['optin'];

        $optinPartner   = $data['optinpartner'];

        $suscribeDate   = $data['inscriptiondate'];
        $suscribeStartIni = $data['inscriptiondate-start'];
        $suscribeEndIni = $data['inscriptiondate-end'];
        $suscribeStart  = \DateTime::createFromFormat('d/m/Y', $suscribeStartIni);
        $suscribeEnd    = \DateTime::createFromFormat('d/m/Y', $suscribeEndIni);

        $hardbounce         = $data['hardbounce'];
        $hardbounceStartIni = $data['hardbounce-start'];
        $hardbounceEndIni = $data['hardbounce-end'];
        $hardbounceStart    = \DateTime::createFromFormat('d/m/Y', $hardbounceStartIni);
        $hardbounceEnd  = \DateTime::createFromFormat('d/m/Y', $hardbounceEndIni);

        $nbpart             = $data['nbpart'];
        $nbpartMin      = $data['nbpart-min'];
        $nbpartMax      = $data['nbpart-max'];
        $nbpartStartIni = $data['nbpart-start'];
        $nbpartEndIni   = $data['nbpart-end'];
        $nbpartStart    = \DateTime::createFromFormat('d/m/Y', $nbpartStartIni);
        $nbpartEnd      = \DateTime::createFromFormat('d/m/Y', $nbpartEndIni);

        $validatedemail = $data['validatedemail'];

        $player         = $data['player'];
        $goldfather     = $data['goldfather'];
        $brain          = $data['brain'];
        $ambassador     = $data['ambassador'];
        $anniversary    = $data['anniversary'];

        /*
         if($gameId != '')  : $gameidFilter = "AND u.id IN (SELECT r FROM PlaygroundGame\Entity\Entry e LEFT JOIN e.user r WHERE e.game = " . $gameId . " GROUP BY e.user)"; else : $gameidFilter = ""; endif;

        switch ($lastName){
        case 'all'      : $lastnameFilter = "WHERE u.lastname IS NOT NULL"; break;
        case 'start'    : $lastnameFilter = "WHERE u.lastname like '" . $lastNameInput . "%'"; break;
        case 'contain'  : $lastnameFilter = "WHERE u.lastname like '%" . $lastNameInput . "%'"; break;
        case 'equal'    : $lastnameFilter = "WHERE u.lastname = '" . $lastNameInput . "'"; break;
        }

        switch ($firstName){
        case 'all'      : $firstnameFilter = ""; break;
        case 'start'    : $firstnameFilter = "AND u.firstname like '" . $firstNameInput . "%'"; break;
        case 'contain'  : $firstnameFilter = "AND u.firstname like '%" . $firstNameInput . "%'"; break;
        case 'equal'    : $firstnameFilter = "AND u.firstname = '" . $firstNameInput . "'"; break;
        }

        switch ($sexe){
        case 'all'      : $sexeFilter = ""; break;
        case 'male'     : $sexeFilter = "AND u.title = 'M'"; break;
        case 'female'   : $sexeFilter = "AND u.title = 'Me'"; break;
        }

        if($memberId == 'equal') : $memberidFilter = "AND u.id = " . $memberIdInput; else : $memberidFilter = ""; endif;

        switch ($email){
        case 'all'      : $emailFilter = ""; break;
        case 'contain'  : $emailFilter = "AND u.email like '%" . $emailInput . "%'"; break;
        case 'equal'    : $emailFilter = "AND u.email = '" . $emailInput . "'"; break;
        }

        switch ($zipcode){
        case 'all'      : $zipcodeFilter = ""; break;
        case 'start'    : $zipcodeFilter = "AND u.postal_code like '" . $zipcodeInput . "%'"; break;
        case 'equal'    : $zipcodeFilter = "AND u.postal_code = '" . $zipcodeInput . "'"; break;
        }

        switch ($birthdate){
        case 'all'      : $birthdateFilter = ""; break;
        case 'between'  : $birthdateFilter = "AND (u.dob >= '" . $dobStart->format('Y-m-d') . "' AND u.dob <= '" . $dobEnd->format('Y-m-d') . "')"; break;
        case 'equal'    : $birthdateFilter = "AND u.dob = '" . $dobEqual->format('Y-m-d') . "'"; break;
        }

        if($hobbies != NULL) {
        foreach($hobbies as $key => $hobby) : $hobbiesSql[] = '\''.$hobby.'\''; endforeach;
        $hobbies = implode(',',$hobbiesSql);
        $hobbiesFilter = "AND u.id IN (SELECT t FROM PlaygroundGame\Entity\PrizeCategoryUser c LEFT JOIN c.user t WHERE c.prizeCategory IN (" . $hobbies . ") GROUP BY c.user)";
        } else {
        $hobbiesFilter = "";
        }

        switch ($optin){
        case 'all'      : $optinFilter = ""; break;
        case 'yes'      : $optinFilter = "AND u.optin = 1"; break;
        case 'no'       : $optinFilter = "AND u.optin = 0"; break;
        }

        switch ($optinPartner){
        case 'all'      : $optinPartnerFilter = ""; break;
        case 'yes'      : $optinPartnerFilter = "AND u.optinPartner = 1"; break;
        case 'no'       : $optinPartnerFilter = "AND u.optinPartner = 0"; break;
        }

        if($suscribeDate == 'all') : $suscribeFilter = ""; else : $suscribeFilter = "AND (u.created_at >= '" . $suscribeStart->format('Y-m-d') . " 00:00:00' AND u.created_at <= '" . $suscribeEnd->format('Y-m-d') . " 00:00:00')"; endif;

        switch ($hardbounce){
        case 'all'      : $hardbounceFilter = ""; break;
        case 'yes'      : $hardbounceFilter = "AND u.isHardbounce = 1"; break;
        case 'no'       : $hardbounceFilter = "AND u.isHardbounce = 0"; break;
        case 'between'  : $hardbounceFilter = "AND u.isHardbounce = 1 AND (u.created_at >= '" . $hardbounceStart->format('Y-m-d') . " 00:00:00' AND u.created_at <= '" . $hardbounceEnd->format('Y-m-d') . " 00:00:00')"; break;
        }

        switch ($nbpart) {
        case 'all'      : $nbpartFilter = ""; break;
        case 'betweennb': $nbpartFilter = "AND u.id IN (SELECT l FROM PlaygroundGame\Entity\Entry m LEFT JOIN m.user l GROUP BY m.user HAVING (COUNT(m.user) >= " . $nbpartMin . " AND COUNT(m.user) <= " . $nbpartMax . "))"; break;
        case 'between'  : $nbpartFilter = "AND u.id IN (SELECT l FROM PlaygroundGame\Entity\Entry m LEFT JOIN m.user l WHERE (m.created_at >= '" . $nbpartStart->format('Y-m-d') . " 00:00:00' AND m.created_at <= '" . $nbpartEnd->format('Y-m-d') . " 00:00:00') GROUP BY m.user)"; break;
        }

        switch ($validatedemail){
        case 'all'      : $validatedemailFilter = ""; break;
        case 'yes'      : $validatedemailFilter = "AND u.state IS NOT NULL"; break;
        case 'no'       : $validatedemailFilter = "AND u.state IS NULL"; break;
        }

        switch ($player){
        case 'all'      : $playerFilter = ""; break;
        case 'bronze'   : $playerFilter = "AND u.id IN (SELECT p FROM PlaygroundReward\Entity\Achievement h LEFT JOIN h.user p WHERE h.category = 'player' AND h.level = 1 GROUP BY h.user)"; break;
        case 'silver'   : $playerFilter = "AND u.id IN (SELECT p FROM PlaygroundReward\Entity\Achievement h LEFT JOIN h.user p WHERE h.category = 'player' AND h.level = 2 GROUP BY h.user)"; break;
        case 'gold'     : $playerFilter = "AND u.id IN (SELECT p FROM PlaygroundReward\Entity\Achievement h LEFT JOIN h.user p WHERE h.category = 'player' AND h.level = 3 GROUP BY h.user)"; break;
        }

        switch ($goldfather){
        case 'all'      : $goldfatherFilter = ""; break;
        case 'bronze'   : $goldfatherFilter = "AND u.id IN (SELECT s FROM PlaygroundReward\Entity\Achievement a LEFT JOIN a.user s WHERE a.category = 'goldfather' AND a.level = 1 GROUP BY a.user)"; break;
        case 'silver'   : $goldfatherFilter = "AND u.id IN (SELECT s FROM PlaygroundReward\Entity\Achievement a LEFT JOIN a.user s WHERE a.category = 'goldfather' AND a.level = 2 GROUP BY a.user)"; break;
        case 'gold'     : $goldfatherFilter = "AND u.id IN (SELECT s FROM PlaygroundReward\Entity\Achievement a LEFT JOIN a.user s WHERE a.category = 'goldfather' AND a.level = 3 GROUP BY a.user)"; break;
        }

        switch ($brain){
        case 'all'      : $brainFilter = ""; break;
        case 'bronze'   : $brainFilter = "AND u.id IN (SELECT b FROM PlaygroundReward\Entity\Achievement n LEFT JOIN n.user b WHERE n.category = 'brain' AND n.level = 1 GROUP BY n.user)"; break;
        case 'silver'   : $brainFilter = "AND u.id IN (SELECT b FROM PlaygroundReward\Entity\Achievement n LEFT JOIN n.user b WHERE n.category = 'brain' AND n.level = 2 GROUP BY n.user)"; break;
        case 'gold'     : $brainFilter = "AND u.id IN (SELECT b FROM PlaygroundReward\Entity\Achievement n LEFT JOIN n.user b WHERE n.category = 'brain' AND n.level = 3 GROUP BY n.user)"; break;
        }

        switch ($ambassador){
        case 'all'      : $ambassadorFilter = ""; break;
        case 'bronze'   : $ambassadorFilter = "AND u.id IN (SELECT d FROM PlaygroundReward\Entity\Achievement f LEFT JOIN f.user d WHERE f.category = 'ambassador' AND f.level = 1 GROUP BY f.user)"; break;
        case 'silver'   : $ambassadorFilter = "AND u.id IN (SELECT d FROM PlaygroundReward\Entity\Achievement f LEFT JOIN f.user d WHERE f.category = 'ambassador' AND f.level = 2 GROUP BY f.user)"; break;
        case 'gold'     : $ambassadorFilter = "AND u.id IN (SELECT d FROM PlaygroundReward\Entity\Achievement f LEFT JOIN f.user d WHERE f.category = 'ambassador' AND f.level = 3 GROUP BY f.user)"; break;
        }

        switch ($anniversary){
        case 'all'      : $anniversaryFilter = ""; break;
        case 'bronze'   : $anniversaryFilter = "AND u.id IN (SELECT g FROM PlaygroundReward\Entity\Achievement j LEFT JOIN j.user g WHERE j.category = 'anniversary' AND j.level = 1 GROUP BY j.user)"; break;
        case 'silver'   : $anniversaryFilter = "AND u.id IN (SELECT g FROM PlaygroundReward\Entity\Achievement j LEFT JOIN j.user g WHERE j.category = 'anniversary' AND j.level = 2 GROUP BY j.user)"; break;
        case 'gold'     : $anniversaryFilter = "AND u.id IN (SELECT g FROM PlaygroundReward\Entity\Achievement j LEFT JOIN j.user g WHERE j.category = 'anniversary' AND j.level = 3 GROUP BY j.user)"; break;
        }

        $query = $em->createQuery('
                SELECT u FROM PlaygroundUser\Entity\User u
                ' . $lastnameFilter . '
                ' . $firstnameFilter . '
                ' . $sexeFilter . '
                ' . $memberidFilter . '
                ' . $emailFilter . '
                ' . $zipcodeFilter . '
                ' . $birthdateFilter . '
                ' . $hobbiesFilter . '
                ' . $optinFilter . '
                ' . $optinPartnerFilter . '
                ' . $suscribeFilter . '
                ' . $hardbounceFilter . '
                ' . $gameidFilter . '
                ' . $nbpartFilter . '
                ' . $validatedemailFilter . '
                ' . $playerFilter . '
                ' . $goldfatherFilter . '
                ' . $brainFilter . '
                ' . $ambassadorFilter . '
                ' . $anniversaryFilter . '
                    
                ');
        */

        //$sql = "SELECT distinct u.user_id, u.username, u.email";
        $sql = "SELECT distinct u.user_id, u.username, u.email, u.title, u.firstname, u.lastname, u.dob, u.address, u.address2, u.postal_code, u.city, u.telephone, u.mobile, u.optin_partner, u.registration_source, u.optin, u.created_at, u.state";

        /*
         if($validatedemail != 'all'){
        $sql .= ', u.state';
        }

        if($birthdate != 'all'){
        $sql .= ', u.dob';
        }

        if($suscribeDate != 'all'){
        $sql .= ', u.created_at';
        }

        if($optin != 'all'){
        $sql .= ', u.optin';
        }
        */

        if ($hardbounce != 'all') {
            $sql .= ', u.date_set_hardbounce';
        }

        $sql .= " FROM user u";

        if (($gameId != '')||($nbpart == 'between')) {
            $sql .= " INNER JOIN game_entry ge ON ge.user_id = u.user_id";
        }

        if ($hobbies != null) {
            $sql .= " INNER JOIN game_prize_category_user pcu ON pcu.user_id = u.user_id";
        }

        if ($player != 'all') {
            $sql .= " INNER JOIN reward_achievement ra1 ON ra1.user_id = u.user_id AND ra1.category = 'player'";
        }
        if ($goldfather != 'all') {
            $sql .= " INNER JOIN reward_achievement ra2 ON ra2.user_id = u.user_id AND ra2.category = 'goldfather'";
        }
        if ($brain != 'all') {
            $sql .= " INNER JOIN reward_achievement ra3 ON ra3.user_id = u.user_id AND ra3.category = 'brain'";
        }
        if ($ambassador != 'all') {
            $sql .= " INNER JOIN reward_achievement ra4 ON ra4.user_id = u.user_id AND ra4.category = 'ambassador'";
        }
        if ($anniversary != 'all') {
            $sql .= " INNER JOIN reward_achievement ra5 ON ra5.user_id = u.user_id AND ra5.category = 'anniversary'";
        }

        $sql .= " WHERE 1=1";

        switch ($lastName) {
            case 'start':
                $sql .= " AND u.lastname like '" . $lastNameInput . "%'";
                break;
            case 'contain':
                $sql .= " AND u.lastname like '%" . $lastNameInput . "%'";
                break;
            case 'equal':
                $sql .=  " AND u.lastname = '" . $lastNameInput . "'";
                break;
        }

        switch ($firstName) {
            case 'start':
                $sql .= " AND u.firstname like '" . $firstNameInput . "%'";
                break;
            case 'contain':
                $sql .= " AND u.firstname like '%" . $firstNameInput . "%'";
                break;
            case 'equal':
                $sql .= " AND u.firstname = '" . $firstNameInput . "'";
                break;
        }

        switch ($sexe) {
            case 'male':
                $sql .= " AND u.title = 'M'";
                break;
            case 'female':
                $sql .= " AND u.title = 'Me'";
                break;
        }

        if ($memberId == 'equal') {
            $sql .= " AND u.user_id = " . $memberIdInput;
        }

        switch ($email) {
            case 'contain':
                $sql .= " AND u.email like '%" . $emailInput . "%'";
                break;
            case 'equal':
                $sql .= " AND u.email = '" . $emailInput . "'";
                break;
        }

        switch ($zipcode) {
            case 'start':
                $sql .= " AND u.postal_code like '" . $zipcodeInput . "%'";
                break;
            case 'equal':
                $sql .= " AND u.postal_code = '" . $zipcodeInput . "'";
                break;
        }

        switch ($birthdate) {
            case 'between':
                $sql .= " AND (u.dob >= '" . $dobStart->format('Y-m-d') . "' AND u.dob <= '" . $dobEnd->format('Y-m-d') . "')";
                break;
            case 'equal':
                $sql .= " AND u.dob = '" . $dobEqual->format('Y-m-d') . "'";
                break;
        }


        switch ($optin) {
            case 'yes':
                $sql .= " AND u.optin = 1";
                break;
            case 'no':
                $sql .= " AND u.optin = 0";
                break;
        }

        switch ($optinPartner) {
            case 'yes':
                $sql .= " AND u.optin_partner = 1";
                break;
            case 'no':
                $sql .= " AND u.optin_partner = 0";
                break;
        }

        if ($suscribeDate != 'all') {
            $sql .= " AND (u.created_at >= '" . $suscribeStart->format('Y-m-d') . " 00:00:00' AND u.created_at <= '" . $suscribeEnd->format('Y-m-d') . " 00:00:00')";
        }

        switch ($validatedemail) {
            case 'yes':
                $sql .= " AND u.state IS NOT NULL";
                break;
            case 'no':
                $sql .= " AND u.state IS NULL";
                break;
        }




        if ($gameId != '') {
            $sql .= " AND ge.game_id=$gameId";
        }
        if ($nbpart == 'between') {
            $sql .= " AND ge.created_at >= '" . $nbpartStart->format('Y-m-d') . " 00:00:00' AND ge.created_at <= '" . $nbpartEnd->format('Y-m-d') . " 00:00:00'";
        }

        //à retirer si la performance est mauvaise
        if ($nbpart == 'betweennb') {
            $sql .= " AND u.user_id IN (SELECT ge.user_id FROM game_entry ge LEFT JOIN user v ON (v.user_id = ge.user_id) GROUP BY ge.user_id HAVING (COUNT(ge.user_id) >= " . $nbpartMin . " AND COUNT(ge.user_id) <= " . $nbpartMax . "))";
        }



        if ($hobbies != null) {
            foreach ($hobbies as $key => $hobby) :
                $hobbiesSql[] = '\''.$hobby.'\'';

            endforeach;
                
            $hobbies = implode(',', $hobbiesSql);
            $sql .= " AND pcu.prize_category_id IN (" . $hobbies . ")";
        }

        switch ($player) {
            case 'bronze':
                $sql .= " AND ra1.level=1";
                break;
            case 'silver':
                $sql .= " AND ra1.level=2";
                break;
            case 'gold':
                $sql .= " AND ra1.level=3";
                break;
        }

        switch ($goldfather) {
            case 'bronze':
                $sql .= " AND ra2.level=1";
                break;
            case 'silver':
                $sql .= " AND ra2.level=2";
                break;
            case 'gold':
                $sql .= " AND ra2.level=3";
                break;
        }

        switch ($brain) {
            case 'bronze':
                $sql .= " AND ra3.level=1";
                break;
            case 'silver':
                $sql .= " AND ra3.level=2";
                break;
            case 'gold':
                $sql .= " AND ra3.level=3";
                break;
        }

        switch ($ambassador) {
            case 'bronze':
                $sql .= " AND ra4.level=1";
                break;
            case 'silver':
                $sql .= " AND ra4.level=2";
                break;
            case 'gold':
                $sql .= " AND ra4.level=3";
                break;
        }

        switch ($anniversary) {
            case 'bronze':
                $sql .= " AND ra5.level=1";
                break;
            case 'silver':
                $sql .= " AND ra5.level=2";
                break;
            case 'gold':
                $sql .= " AND ra5.level=3";
                break;
        }

        $rsm = new ResultSetMapping();

        $query = $em->createNativeQuery($sql, $rsm);

        //echo $sql;

        $method = new \ReflectionMethod($query, '_doExecute');
        $method->setAccessible(true);
        $result = $method->invokeArgs($query, array());
        //$result = $query->execute(array(),\Doctrine\ORM\Query::HYDRATE_ARRAY);
        return $result;
    }
1245004
public function afterSave(Event $event, EntityInterface $entity) {
		if ($this->getConfig('uploadOn') === 'afterSave') {
			$this->_handleFiles($entity);
		}
	}
1036033
public static function get_records_select($select, $params = null, $sort = '', $fields = '*', $limitfrom = 0, $limitnum = 0) {
        global $DB;

        $records = $DB->get_records_select(static::TABLE, $select, $params, $sort, $fields, $limitfrom, $limitnum);

        // We return class instances.
        $instances = array();
        foreach ($records as $key => $record) {
            $instances[$key] = new static(0, $record);
        }

        return $instances;

    }