user742736
user742736

Reputation: 2729

Symfony/Doctrine Return results from multiple entities

Is it possible to return results from multiple entities?

Eg: Entity1, Entity2, Entity3, Entity4

Each Entity will have a column title. There will be a where statement on the title field to return the filtered record.

The entities do not have a relationship with each other.

I was thinking of putting it in the Entity1Repository but the filter will only filter records from Entity1

The only solution I can think of is to get the results for each entity and combine all the results.

Upvotes: 1

Views: 989

Answers (1)

Adam
Adam

Reputation: 71

You can return results as array

->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);

and merge it. array_merge() Or entity repository.

Upvotes: 0

Related Questions