[英]How do you insert binary data into a BLOB column with Class::DBI?
I want to create a new object using Class::DBI. 我想使用Class :: DBI创建一个新对象。 One of the fields of this object is a BLOB type. 此对象的字段之一是BLOB类型。 I have a filehandle I want to use for this data, but apparently, just doing this doesn't work: 我有一个要用于此数据的文件句柄,但显然,仅这样做是行不通的:
my $item = My::Class::DBI::Class->insert({
foo => $bar,
biz => $baz,
blob => $my_filehandle
});
Is there some trick I am missing? 我缺少一些技巧吗?
Thanks! 谢谢!
You have to read out the filehandle, and insert that. 您必须读出文件句柄,然后将其插入。
my $blob = do {local $/; <$my_filehandle>};
my $item = My::Class::DBI::Class->insert({
foo => $bar,
biz => $baz,
blob => $blob,
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.