我的 services.xml 中有服务
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
</service>
<service id="my.main" class="%my.main.class%">
<call method="foo">
<argument type="service" id="tmcyc.connection" />
</call>
</service>
但出现错误:
可捕获的致命错误:传递给 Doctrine\Bundle\DoctrineBundle\ ConnectionFactory::__construct() 的参数 1 必须是一个数组,没有给出...
如何传递带参数的数组?例如:
<service id="my.connection" class="Doctrine\Bundle\DoctrineBundle\ConnectionFactory">
<argument>[ARRAY]</argument>
</service>
或者我做错了什么?因为这段代码工作得更好:
$connectionFactory = $this->getContainer()->get('doctrine.dbal.connection_factory');
$conn = $this->createConnection($this->conn);
$conn->executeQuery('SET NAMES utf8');