我是 Symfony2 的新手。我正在开发一个实用服务,它需要使用数据库来满足自己的需求。
我希望它的数据与其他服务/捆绑使用的 mysql 全局数据库分开。
存储 db 文件的最佳位置在哪里以及如何指定路径?
示例(错误)代码:
class MyCustomService
{
protected $config;
public function __construct(array $config)
{
$this->config = $config;
$this->setupDB();
}
private function setupDB()
{
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'driver' => 'pdo_sqlite',
'path' => realpath('.') . '\dbmanager.db'
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
//...
}
}
谢谢你的帮助