[ABE.pm] And another thing...

Faber J. Fedor faber at linuxnj.com
Mon May 22 21:49:43 PDT 2006


On 22/05/06 23:40 -0400, Ricardo SIGNES wrote:
> * "Faber J. Fedor" <faber at linuxnj.com> [2006-05-22T22:09:55]
> > On 22/05/06 14:00 -0400, Ricardo SIGNES wrote:
> > > > Not at all.  As I stated before, my problem was not calling the base
> > > > class' construstor when I created the derived class.
> > > 
> > > ...but with the code I provided, you don't need to do that.  
> > 
> > I understand that.  What I was trying to do was to build on the $self
> > object, i.e. my base class defines $self->{date}, $self->{template},
> > etc. which all of the derived classes need.  Then each derived class
> > adds to $self the variables the derived class needs.  This way I don't
> > need to call '$dbh = get_dbh()' in every function that needs to do a SQL
> > stmt (which are quite a few).
> 
> ...but then don't you end up always having to say, for example:
> 
>   my $dbh = $self->{dbh};
>   # or
>   my $sth = $self->{dbh}->prepare(...)

You know, I've never used prepare() all that much in my coding.  Most of my
UPDATES are one-liners (one-tuplers? :-) and most of my INSERTS are mass
INSERTs better done by LOAD DATA INFILE. Most of my
variables are in the WHERE or other subordinate clauses because I'm
doing far more SELECTS than anything else.

> What I'm wondering is why it's not better to say:
> 
>   my $sth = $self->dbh->prepare(...);
> 
> ...where the dbh method is the get_dbh method with a few fewer chars.  

How do you get from get_dbh() to 'my $sth = $self->dbh' or even 'my $sth
= $self->{dbh}'? You dropped a 'get_' in there!

Most of my code has been

    my @returnedRow = $self->{"_DBH"}->selectrow_array($stmt);

or selecatall_hashref, etc.

> I feel
> like one of us is missing something, and it very well may be me!

Well, this could be a first! :-)

-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the ABE-pm mailing list