Spidy has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing some database code that involves modules, but I'm having a strange issue.
Inside my module(Main.pm), I have this piece of code:
Which is ideally supposed to take the database connection passed to it, so that the module can use it. However, I'm having some issues. Inside my main script, I do this:
and then later on,
However, I'm getting an error for Main.pm, which is
Spidy
Inside my module(Main.pm), I have this piece of code:
my $dbh; sub new { $dbh = @_; }
Which is ideally supposed to take the database connection passed to it, so that the module can use it. However, I'm having some issues. Inside my main script, I do this:
# $dbname, $uname, $pword have already been filled in. my $dbh = DBI->connect("DBI:mysql:$dbname:localhost","$uname","$pword" +);
and then later on,
Main::new($dbh);
However, I'm getting an error for Main.pm, which is
Anyone have any ideas?Can't locate object method "selectrow_array" via package "Main" at Mai +n.pm line ***.
Spidy
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Passing a database connection
by dragonchild (Archbishop) on Nov 22, 2005 at 21:33 UTC | |
by aufflick (Deacon) on Nov 23, 2005 at 00:30 UTC | |
by Spidy (Chaplain) on Nov 22, 2005 at 21:36 UTC | |
Re: Passing a database connection
by doob (Pilgrim) on Nov 22, 2005 at 21:35 UTC | |
by ikegami (Patriarch) on Nov 22, 2005 at 21:37 UTC | |
by dragonchild (Archbishop) on Nov 23, 2005 at 02:23 UTC | |
by doob (Pilgrim) on Nov 23, 2005 at 19:24 UTC | |
Re: Passing a database connection
by techcode (Hermit) on Nov 24, 2005 at 00:10 UTC |
Back to
Seekers of Perl Wisdom