sub AUTOLOAD { my $self = shift; my $type = ref($self) || $self; return if $AUTOLOAD =~ /::DESTROY$/; my $name = $AUTOLOAD; $name =~ s/.*://; my $dbh = BSN::DB::connect(); my $sql = "select * from method_tbl where name='".$name."' and type='".$self->{_type}."'"; my $sth = $dbh->prepare($sql); $sth->execute(); my $ref = $sth->fetchrow_hashref(); unless (exists $ref->{body}) { $sql = "select * from method_tbl where name='".$name."' and type='Default'"; $sth = $dbh->prepare($sql); $sth->execute(); $ref = $sth->fetchrow_hashref(); unless (exists $ref->{body}) { return "Can't access `$name' method in class ".$self->{_type}; } } my $call = eval("$ref->{body}"); if ($@) { croak "Method Error: $@ in method `$name' in class $type"; } unshift @_,$self; goto &$call; }