douxing8855 2014-02-27 09:20
浏览 99

PDO SQLite:无法打开数据库文件[关闭]

I create a project in Symfony and encountered a bug #57785. Apparently a bug and remains unresolved.

Who knows a way around this bug?

I will explain the problem

I created a portable app. Such application, the user normally installs on the Desktop or My Documents.

Example bad path for Russian:

C:\Documents and Settings\Администратор\Рабочий стол\
C:\Documents and Settings\Администратор\Мои документы\

I can restrict the user to install the application in such a directory, but it is bad practice.

Сan change assembly dsn in the package doctrine/dbal, but it is a very tough decision that will not always work:

Doctrine\DBAL\Driver\PDOSqlite\Driver::_constructPdoDsn(array $params)
{
    $dsn = 'sqlite:';
    if (isset($params['path'])) {
        $dsn .= iconv('cp1251', 'utf-8', $params['path']);
    } else if (isset($params['memory'])) {
        $dsn .= ':memory:';
    }

    return $dsn;
}

Necessary get the Doctrine database driver and replace path to database file after changing the encoding.

$conn = $this->container->get('doctrine')->getConnection();
$new_path = iconv('cp1251', 'utf-8', $conn->getParams()['path']);
// further necessary change connection params
  • 写回答

1条回答 默认 最新

  • dongru3726 2014-02-27 09:25
    关注

    I know. Just don't use fancy catalog names on your server.

    /var/www/project/db/
    

    would be either sane and readable by any software

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘