最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Symfony2 在service中如何使用Doctrine
时间:2022-06-25 02:49:29 编辑:袖梨 来源:一聚教程网
在service中有个方法需要调用Doctrine,使用
代码如下 | 复制代码 |
$user = $this->getDoctrine()->getRepository('AtotrukisMainBundle:User') |
提示"getDoctrine"找不到,那么我们应该怎么做呢?
解决方法:
第一步:
在service配置文件中添加arguments
代码如下 | 复制代码 |
eventService: class: Atotrukis\MainBundle\Service\EventService arguments: ["@doctrine.orm.entity_manager"] |
第二步:
在service对应的class:Atotrukis\MainBundle\Service\EventService中增加如下代码:
代码如下 | 复制代码 |
protected $em; public function __construct($em) { $this->em = $em; } |
相关文章
- 奇迹暖暖卷二10-6高分有哪些搭配思路 04-30
- 老头看到一美女大冬天还穿超短裙 04-30
- 我看看,在哪一层啊? 04-30
- 我满脸通红的说:这是首付 04-30
- 面试时候也把自己说的很牛B的样子 04-30
- 你们的菜要慢点上,厨师去买土豆了…… 04-30