I know this solution is quite hacky, but I don't really have another idea right now. Try to add the following accessor to your resultsource class
sub col_name { my $self = shift; if (@_) { my $data = shift; my $sth = $self->result_source->schema->storage->dbh->prepare( +"update table set col_name = ? where primary_key = ?"); $sth->bind_param(1, $data, {TYPE => DBI::SQL_BINARY}); $sth->bind_param(2, $self->primary_key); $sth->execute; } my $sth = $self->result_source->schema->storage->dbh->prepare("sel +ect col_name from table where primary_key = ?"); $sth->execute( $self->primary_key ); my $result = $sth->fetchrow_hashref; return $result->{col_name}; }
I know that this piece of code somehow undermines the principles of DBIx::Class because the resultsource already knows what the table name is and how the primary_key is called. You may be able to change the hard-coded SQL queries to something smarter or you will probably also be able to use SQL::Abstract, which DBIx::Class uses internal as well, to build that query, but I didn't bother with that.
Also note that the code is completely untested.
Cheers, Flo
In reply to Re: Updating/inserting Binary data using DBIx::Class
by rafl
in thread Updating/inserting Binary data using DBIx::Class
by hrr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |