I am trying to store a serialized object into my database table in Laravel. I want to save it as a LONGBLOB however, Laravel does not support this in blue prints and only allows me to save as a binary() which is the BLOB equivalent.
Inside my migration, it looks like this:
public function up()
{
Schema::create('platforms', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('name');
$table->binary('classifier');
$table->integer('steps')
->default(10000);
$table->timestamps();
});
}
When I try to then save my serialized object to the database like so:
protected function storeClassifier($blob, $ainame) {
DB::table('platforms')->insert(
[
'user_id' => \Auth::user()->id,
'name' => $ainame,
'classifier' => $blob
]
);
}
I get this error:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'classifier' at row 1
How can I create a LONGBLOB column for classifier inside my migration? The full object serialized looks like this (extremely big).
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2CPZ2kv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire