doctrine extra lazy load doesn't work as expected with count

前端 未结 2 2054
春和景丽
春和景丽 2021-02-09 16:41

I have an entity Shop and a related entity ShopProduct, with the following relation:

/**
 * @OR         


        
2条回答
  •  梦如初夏
    2021-02-09 17:39

    Just encountered the same problem and the solution was very simple:

    {{ value.getAlerts.count() }}

    instead of

    {{ value.getAlerts.count }}

    Twig must be overriding the Doctrine count() method meant to "Extra Lazy Load" with a variant of it's own implementation that just dumbly fetches all entities to count them.

    That turned all expected SELECT * queries into COUNT(*)...

提交回复
热议问题