Re: Inherit a database connection object
- From: tom@xxxxxxxxxxxxxx (Tom Phoenix)
- Date: Sun, 24 Jun 2007 11:33:52 -0700
On 6/24/07, Patrik Hasibuan <patrikh@xxxxxxxxxxxxxxxxxxxxx> wrote:
I want to write once a script as a part of building a connection to my MySQL
DB server. The parts only use a kind of vabiable such as "$dbh". Is it possible?
It's possible. In fact, that's what most of us do with objects.
#!/usr/bin/perl -w
That's a good start. You could also use "use warnings" instead of -w,
and adding "use strict" will prevent some common mistakes.
use strict;
use warnings;
use iterdir;
What's this? Module names in all lower case are reserved for pragmas.
In the privacy of your own home directory, of course, you can name
things whatever you want. But normal modules, and the package names
they use, begin with a capital letter.
Can't call method "prepare" on an undefined value at iterdir.pm line 22.
That means that the expression to the left of "->prepare" near line 22
turned out to be undef instead of an object.
Please tell me how a class inherits connection object to the another class.
Perl objects use the @ISA mechanism, documented in the perlobj manpage.
http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlobj.pod
But it may help to start in the barnyard:
http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlboot.pod
Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
.
- Follow-Ups:
- Re: Inherit a database connection object
- From: Patrik Hasibuan
- Re: Inherit a database connection object
- From: Patrik Hasibuan
- Re: Inherit a database connection object
- References:
- Inherit a database connection object
- From: Patrik Hasibuan
- Inherit a database connection object
- Prev by Date: Re: Proper class setup?
- Next by Date: Re: Conditional in regex
- Previous by thread: Inherit a database connection object
- Next by thread: Re: Inherit a database connection object
- Index(es):
Relevant Pages
|