Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^5: A Growing Dislike for SQL-OOP Mappers

by itub (Priest)
on Aug 22, 2005 at 22:28 UTC ( #485785=note: print w/ replies, xml ) Need Help??


in reply to Re^4: A Growing Dislike for SQL-OOP Mappers
in thread A Growing Dislike for SQL-OOP Mappers

I never said "don't override it", I even proposed two ways you could do it! This is a general situation: if you want to override method A so that it calls method B, and you know that method B will call method A, you can fix the loop by overriding method B. For example,

package MyApp::DBI; use base 'Class::DBI'; __PACKAGE__->connection(...); 1; package MyApp::Gallery; use base 'MyApp::DBI'; __PACKAGE__->table('galleries'); __PACKAGE__->columns(...); sub create { my ($self, $ops) = @_; my $dir = $ops->{'directory'}; if (-e $dir) { die 'directory exists'; else { mkdir $directory; $self->find_or_create($data); }; return; }; sub find_or_create { my $class = shift; my $hash = ref $_[0] eq "HASH" ? shift: {@_}; my ($exists) = $class->search($hash); return defined($exists) ? $exists $class->SUPER::create($hash) +; } 1;


Comment on Re^5: A Growing Dislike for SQL-OOP Mappers
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://485785]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-04 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls