我試圖在更新或檢索時操縱列的數據。例如,在它進入數據庫之前,我想對它進行加密,並且每當它被訪問時,我想解密它。我正在關注DBIx::Class::Manual::Cookbook中的這個示例,但我似乎無法使其工作。我在用戶架構中放置了以下內容。爲了測試我只是使用name列,我知道這是沒有意義的:DBIx :: Class使用DBIx :: Class包裝/重載列訪問器
__PACKAGE__->add_columns("name" => { accessor => '_name' });
sub name {
my $self = shift;
# If there is an update to the column, we'll let the original accessor
# deal with it.
if(@_) {
return $self->_name('test 1');
}
# Fetch the column value.
my $name = $self->_name;
$name = 'test 2';
return $name;
}
我看不到我在做什麼比菜譜說的話有什麼不同。任何人都不能幫助我理解我做錯了什麼嗎?謝謝!
它怎麼樣? – friedo 2012-07-17 20:58:20
它只是功能好像我的名字功能不存在。 – srchulo 2012-07-17 23:22:26
你能告訴我們一段代碼不工作,你期望它返回什麼,它實際返回的是什麼? – RickF 2012-07-24 15:43:53