我有服務在我的services.xmlSymfony的2傳球達陣在service.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>
,但得到的錯誤:
Catchable Fatal Error: Argument 1 passed to Doctrine\Bundle\DoctrineBundle\ ConnectionFactory::__construct() must be an array, none given...
如何傳遞數組參數? 例如:
<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');
這應該是被接受的答案,更具有示範性。 – chalasr 2016-06-29 19:37:22