duanjia7607 2015-02-18 10:23
浏览 23

symfony2 doctrine如何删除查询中的相关对象?

I have, for example, a "products" entity and an "orders" entity and a "customers" entity. using doctrine, if I execute

return $this->getEntityManager()
        ->createQuery(
            'SELECT p FROM MyApplicationBundle:Products p ORDER BY p.name ASC'
        )
        ->getResult();

I get a collection of products with orders and customers related information. this collection is too big and I'm worried it can take too much memory. is there a way to take only the products information? I'd need it only for this query so I don't want to modify the relation in the product entity class.

thanks

  • 写回答

1条回答 默认 最新

  • dongsisui7562 2015-02-18 10:52
    关注

    You can mark the association as Extra Lazy in your Entity, this should prevent it from being automatically included in your query.

    评论

报告相同问题?

悬赏问题

  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。