How do I override autogenerated accessors in Perl's Class::DBI? -


I wanted to modify the URL before inserting the database on

I:

  Package Hosting :: Company; Use Base 'Class :: DBI'; My $ class = __PACKAGE__; $ Square & gt; Table ('companies'); $ Square-> column (primary = & gt; 'company id'); $ Square-> column (other => qw / name url comment); Sub URL {My $ self = shift; # Modify the URL if (@_) {$ _ [0] = 'Aaaaa'; # Return $ self-> _Url_accessor ('Aaaaa'); - Either does not work} # Return to normal class: DBI back $ self-> _Url_accessor (@_); }  

But this does not work:

  My $ company = hosting :: company-> Insert ({name = & gt; 'test', url = & gt; 'http: // http: // url'}); Print $ Company- & gt; URL, "\ n";  

Show:

  http: // http: // url  

I want a class: DBI mailing The list was still alive!

Do not change insert by overriding an accelerator. The best way to handle data normalization is to override but it's okay, your accessor has been exposed.

PS is still active, just have not seen so much posting. Most people have gone on this.


Comments