How do I insert binary data into a column of type BLOB of a SQLite database in Laravel?
1 Answer
If column in your table is BLOB type, e.g. you created it in migration like this:
Schema::table('images', function($table) {
$table->binary('data');
})
Then you should be able to insert binary data by using regular insert() method:
DB::table('images')->insert([
'data' => $binaryFile
]);
Or like this:
DB::table('test')->insert([
'data' => DB::raw("LOAD_FILE('/path/to/file')")
]);
1 Comment
izuchy
Thank you. It tried several try , but eventually was implemented in x'1234567'. sqlite.1065341.n5.nabble.com/Inserting-BLOB-values-td3611.html