相关疑难解决方法(0)

Laravel + SQLite = SQLSTATE [HY000]常规错误:8尝试编写只读数据库

我正在尝试删除db.sqlite文件,再次创建它,然后在同一个方法中插入一些信息,这是我正在使用的方法:

public function destroy()
{
    // Store all contents and delete the first one since this is created via seeder
    $contents = $this->contents->all()->toArray();
    array_shift($contents);

    // Delete db file, creates it from an example file and changes permissions
    system('rm -rf ../database/database.sqlite');
    system('cp ../database/database.sqlite.example ../database/database.sqlite');
    system('chmod 0777 ../database/');
    system('chmod 0777 ../database/database.sqlite');

    // Insert data
    foreach ($contents as $content) {
        $this->contents->create($content);
    }

    return response()->json(['message' => 'Data has been destroyed!']);
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试运行它时,我得到标题上描述的错误:

SQLSTATE[HY000]General Error: 8 attempt to write a readonly database

我给了文件的777权限和其他问题答案推荐的文件夹 …

php linux sqlite ubuntu laravel

4
推荐指数
2
解决办法
5498
查看次数

标签 统计

laravel ×1

linux ×1

php ×1

sqlite ×1

ubuntu ×1