最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Symfony2 在service中如何使用Doctrine
时间:2014-11-07 编辑:简简单单 来源:一聚教程网
在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; } |
-
下一个: php异步多线程swoole使用实例程序
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24