本文整理汇总了PHP中Nette\Database\Connection::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::__construct方法的具体用法?PHP Connection::__construct怎么用?PHP Connection::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Connection
的用法示例。
在下文中一共展示了Connection::__construct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($dsn, $user = NULL, $password = NULL, array $options = NULL)
{
$container = \Testbench\ContainerFactory::create(FALSE);
$this->onConnect[] = function (NetteDatabaseConnectionMock $connection) use($container) {
if ($this->__testbench_databaseName !== NULL) {
//already initialized (needed for pgsql)
return;
}
try {
$config = $container->parameters['testbench'];
if ($config['shareDatabase'] === TRUE) {
$registry = new \Testbench\DatabasesRegistry();
$dbName = $container->parameters['testbench']['dbprefix'] . getenv(\Tester\Environment::THREAD);
if ($registry->registerDatabase($dbName)) {
$this->__testbench_database_setup($connection, $container, TRUE);
} else {
$this->__testbench_databaseName = $dbName;
$this->__testbench_database_change($connection, $container);
}
} else {
// always create new test database
$this->__testbench_database_setup($connection, $container);
}
} catch (\Exception $e) {
\Tester\Assert::fail($e->getMessage());
}
};
parent::__construct($dsn, $user, $password, $options);
}