Php Laravel-动态读取SQLite文件

Php Laravel-动态读取SQLite文件,php,sqlite,laravel,laravel-5,laravel-5.1,Php,Sqlite,Laravel,Laravel 5,Laravel 5.1,我正在尝试一个项目,该项目通过上传接受SQLite文件,保存它,并解析SQLite数据库中的数据。我发现,当我使用较小的DB文件时,不会创建“-wal”和“-shm”文件,但当使用较大的DB(至少2mb)时,会创建“-wal”和“-shm”文件 以下是我正在使用的代码: $destination = storage_path().'/tempDir/databases/'.$userId.'/'; //store the file in the directory $request->f

我正在尝试一个项目,该项目通过上传接受SQLite文件,保存它,并解析SQLite数据库中的数据。我发现,当我使用较小的DB文件时,不会创建“-wal”和“-shm”文件,但当使用较大的DB(至少2mb)时,会创建“-wal”和“-shm”文件

以下是我正在使用的代码:

$destination = storage_path().'/tempDir/databases/'.$userId.'/';

//store the file in the directory
$request->file('database')->move($destination .'database/database.db');

$destination = $destination.'database/database.db';
Config::set('database.connections.sqlite.database', $dbLocation);
$sqliteDbConnection = \DB::connection('sqlite');
$getUsers = $sqliteDbConnection->table("users")->get();
每当我尝试执行此操作时,都会出现以下错误: “SQLSTATE[HY000]:一般错误:10磁盘I/O错误(SQL:从\“用户\”中选择*)”

有人知道为什么会这样吗?我可以确认保存到服务器的文件处于良好状态,我可以用其他SQLite查看器打开它

更新:Homestead和my MAC之间的链接是否可能禁止Laravel访问该文件


更新2:问题100%在于VirtualBox和计算机之间的共享机制。我通过XAMPP尝试了这个,效果很好。WTF?

这就是我如何使用自定义PDO连接获取生成器实例的方法:

$pathname = '/absolute/path/to.sqlite';

$connection = new \Illuminate\Database\SQLiteConnection(new \PDO('sqlite:' . $pathname));

$builder = new \Illuminate\Database\Query\Builder($connection);

$builder->newQuery()->from('my_table')->get()->all();

我会选择PDO,而不是尝试将数据库传递给laravel:
$db=newPDO('sqlite:'。$destination)好的,那么我如何访问数据库中的信息呢?就像这样:谢谢。当我尝试实现您的示例时,prepare()方法返回false。知道为什么吗?捕捉并检查错误: