[freeside] Stuck on a hashref and mod_perl
ivan
ivan at 420.am
Thu Jun 22 03:41:42 PDT 2000
On Wed, Jun 21, 2000 at 10:52:24PM -0400, Stephen Amadei wrote:
>
> I have been very unsuccessful trying to lowercase my column names
> returned from a fetchrow_hashref. As some of you may remember, I am
> trying to hack Freeside to work on DB2... as I get time, as least.
Now that it's there, we should probably move this over to the devel list.
> One thing, is the DB2 returns the columns in the hashref as uppercase,
> and DB2 doesn't return a number of rows from $sth->execute... so
> I modified the qsearch and new methods to get around these shortcomings,
Yes, you're not supposed to count on that behaviour. It's in the TODO:
Portability: in FS::Record, $sth->execute does not return a number of
rows for all DBD's. see man DBI
So I'd be interested getting a copy of those changes if you can isolate
them.
> but apparently this upsets the 'majik' holding the PERL together, and I
> get a
> "Can't call method "hashref" on an undefined value at
> d:/apache/htdocs/freeside/browse/svc_acct_pop.pl line 65"
> I think I understand the error... but I don't understand why my valid
> hash in "new" doesn't come out in line 65 or svc_acct_pop.pl:
> my($hashref)=$svc_acct_pl->hashref;
I'm assuming you've changed htdocs/browse/svc_acct_pop.cgi to
svc_acct_pop.pl; seems like you've got that working fine. I'm confused as
to why you've also changed it in that line; here's the relevant section of
code:
foreach $svc_acct_pop ( sort {
$a->getfield('popnum') <=> $b->getfield('popnum')
} qsearch('svc_acct_pop',{}) ) {
my($hashref)=$svc_acct_pop->hashref;
$svc_acct_pop in the last line references the $svc_acct_pop in the foreach
statement.
One possibility is that since you've changed it to $svc_acct_pl, that
variable is automatically created when referenced with the undefined
value. This is the sort of trap that `use strict;' is supposed to avoid
(see `perldoc strict') - have you removed it?
Another possibility is that your modifications have caused the qsearch()
call to return one or more undefined values (since it's called in list
context, it returns a list).
> I have spent an embarressingly long amount of time on this... ;-)
>
> BTW, I haven't gotten to the point where persisiant DB connections
> are needed, but I am a little confused as to exactly what I will need...
> I have Apache 1.3.12 with SSL and PHP4, and my PERL is up to date 5.005
> with the Apache_DBI needed for the persistant connections... do I still
> need mod_PERL, or can PHP4 handle the persisant connections?
Yes, you need to use mod_perl and Apache::DBI for persistant database
connections. PHP4 may be able to handle persistant database connections
within the context of PHP, but that wouldn't affect things running under
mod_perl.
--
meow
_ivan
More information about the freeside-users
mailing list