简体   繁体   中英

Inserting binary data into BLOB columns

如何在Laravel中将二进制数据插入SQLite数据库的BLOB类型的列中?

If column in your table is BLOB type, eg 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')")
]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM