This same $self->{'dbh'} is working in every other method of this module, but seems to have gone South on me in this code. It prepares a query and produces what looks to be a $sth. But when I execute the $sth, it returns 1, which has no ->fetchrow_hashref() method.
Any ideas would be appreciated.
my $sql = $self->{'cfg'}->param("sql.get_service_plans");
$self->log('The $service_plans query reads: ',$sql);
my $sth = $self->{'dbh'}->prepare($sql) or die $self->{'dbh'}->errst
+r;
$self->log('It\'s $sth looks like this: ',$sth);
my $service_plans = $sth->execute() or die $self->{'dbh'}->errstr;;
$self->log('The $service_plans query looks like this: ',$service_pla
+ns);
while (my $plan = $service_plans->fetchrow_hashref()){
print Dumper($plan);
}
And from the logs:
The $service_plans query reads:
$VAR1 = 'SELECT svc_plan_id, plan_name, plan_image, plan_description,
+plan_deposit, plan_monthly_fee, plan_prepaid_discount, plan_list_size
+, plan_group_count FROM svc_plans WHERE plan_active ORDER BY plan_sor
+t_order';
It's $sth looks like this:
$VAR1 = bless( {}, 'DBI::st' );
The $service_plans query looks like this:
$VAR1 = 1;
Can't call method "fetchrow_hashref" without a package or object refer
+ence at . . .
Thanks,
-- Hugh
UPDATE:
Thanks targetsmart, a second set of eyes got me past that one in a handful of minutes. Your help is appreciated. -- HE
if( $lal && $lol ) { $life++; }
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.