Thread Perl-OO und Vererbung (6 answers)
Opened by nepos at 2005-09-08 13:19

renee
 2005-09-08 13:35
#57748 #57748
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Mach noch eine Hilfsklasse...

in etwas so:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package YourClass;

[... use strict etc ...]]
our @ISA = qw(DBI);

[... andere Methoden ...]

sub prepare{
my ($self,@params) = @_;
my $sth = SUPER::prepare(@params);
my $nr = ++$self->{nr};
push(@{$self->{sth}},$sth);
my $tmpObj = HelperClass->new($self,$sth,$nr);
return $tmpObj;
}

sub execute{
my ($self,$nr,@params) = @_;
[... logging ...]
$self->{sth}->[$nr]->execute(@params);
}


Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
package HelperClass;
sub new{
my ($class,$parent,$nr) = @_;
my $self = {};
bless $self,$class;
$self->{parent} = $parent;
$self->{nr} = $nr;
}

sub execute{
my ($self,@params) = @_;
$self->{parent}->execute($nr,@params);
}


ungetestet!

edit: so ähnlich musst Du das dann halt mit allen DBD::st-Methoden machen...\n\n

<!--EDIT|renee|1126172228-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Perl-OO und Vererbung