改变推进连接
Change Propel Connection
我正在尝试为单元测试配置 Propel。我已经为测试目的创建了第二个连接,但我一直无法弄清楚如何让 propel 使用它。连接如下所示:
connectionForTests:
adapter: mysql
dsn: mysql:host=localhost;port=3306;dbname=code_test
user: root
password: root
settings:
charset: utf8
而且我看过 propel 文档,关于如何让 propel 实际使用不同的连接的信息并不多。我是否设置环境变量,运行 ConnectionFactory
上的函数,或类似的东西?
我在 dev-master
使用 Propel2,我没有将它作为 Symfony 的一部分使用。
我是通过以下方式完成的:
$default = Propel\Runtime\Propel::getConnectionManager('default');
$test = Propel\Runtime\Propel::getConnectionManager('connectionForTests');
$config = $test->getConfiguration();
$default->setConfiguration($config);
在我的 PHPUnit bootstrap 文件中。
我正在尝试为单元测试配置 Propel。我已经为测试目的创建了第二个连接,但我一直无法弄清楚如何让 propel 使用它。连接如下所示:
connectionForTests:
adapter: mysql
dsn: mysql:host=localhost;port=3306;dbname=code_test
user: root
password: root
settings:
charset: utf8
而且我看过 propel 文档,关于如何让 propel 实际使用不同的连接的信息并不多。我是否设置环境变量,运行 ConnectionFactory
上的函数,或类似的东西?
我在 dev-master
使用 Propel2,我没有将它作为 Symfony 的一部分使用。
我是通过以下方式完成的:
$default = Propel\Runtime\Propel::getConnectionManager('default');
$test = Propel\Runtime\Propel::getConnectionManager('connectionForTests');
$config = $test->getConfiguration();
$default->setConfiguration($config);
在我的 PHPUnit bootstrap 文件中。