B
B
BonBon Slick2018-05-23 12:14:29
Doctrine ORM
BonBon Slick, 2018-05-23 12:14:29

How to cache native SQL?

https://www.doctrine-project.org/projects/doctrine...
I only see DQL caching here.
How to cache this?

$select = '
                SELECT * FROM users ' . $alias . '
                ORDER BY ' . $alias. '.created_at ASC
            ';

            $rsm = new ResultSetMappingBuilder($this->entityManager);
            $rsm->addRootEntityFromClassMetadata(User::class, $this->usersAlias);

            $query = $this->entityManager->createNativeQuery($select, $rsm);

            return $query->getResult();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2018-05-23
@BonBonSlick

$cache_id = md5($select);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question