存储我的服务sqlite db文件的最佳位置?

前端之家收集整理的这篇文章主要介绍了存储我的服务sqlite db文件的最佳位置?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是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); 

       //...
    }
}

谢谢你的帮助

解决方法

It Shouldn't be in web folder :)

>如果您的数据库可以在清除缓存时删除,那么app / cache就可以了.
>如果你想要持久数据库,那么你可以选择app / {name of service} /db.sqlite“或data / {name of service} /db.sqlite”中的某个地方
>我宁愿在配置选项中传递DB的名称

Also note that under *NIX the user of your web server/cli must have read and write permissions on the database file and read,write and execute permissions on the containing directory

猜你在找的Sqlite相关文章