|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
On Monday 26 Jan 2004 4:07 pm, Phil Lawrence wrote:
> Malcolm wrote:
> > my $hash = {'some'=>'data'};
> > my $quoted = $dbh->quote($hash->{'some'});
> > at which point $quoted is undefined.
> I suggest 1, 2, or 3 things:
> 1. Use Data::Dumper;
> print Dumper($hash);
Which results in some odd things:
my $hash = {'some'=>'data'};
print $dbh->quote($hash->{'some'});
print Dumper($hash);
produces:
'data'
$VAR1 = { 'some' => 'data' };
However, using the actual data:
print Dumper($session);
$VAR1 = { 'errors' => undef, 'refering_page' => '', 'name' => undef, 'logged
in' => 'y', 'cookie' => '0167d73142462923e29ef694839a26c2', 'username' =>
'tESTING', 'previous args' => undef, '_session_id' =>
'0167d73142462923e29ef694839a26c2', 'redirect' => undef, 'last used' =>
1075156417 };
my $username = $session->{'username'};
print $username;
gives: tESTING
print $session->{'username'};
gives: tESTING
print $$session{'username'};
gives: tESTING
print $dbh->quote( $session->{'username'} );
gives: NULL
print $dbh->quote( ${ \$session->{'username'} } );
gives: NULL
my %session = %$session;
print $dbh->quote( $session{username} );
gives: 'tESTING'
print $dbh->quote($username);
gives: 'tESTING'
> 2. Not a suggestion, but did you know that DBI
> auto-quotes bound in variables?
In theory. As I was dealing with some fairly simple SQL I didn't consider
them.
> 3. sprinkle debug print statements in the DBI
> source. The quote method is only a few lines long...
Erm... how?
Editing DBI.pm doesn't seem to have any effect (added a "warn" with the
parameters as an initial test, restarted apache, nothing shows in the error
log).
On Monday 26 Jan 2004 4:14 pm, Gay, Jerry wrote:
> have you dumped the hash reference to make sure the value for the 'some'
> key is defined?
Yes, see above.
> then again... since the variable is tied, it might be the cause of the
> problem.
It's looking that way. If I get the data via the tied hash, it doesn't work.
If I assign exactly the same data to a normal hash, it works.
> you might be able to create an anonymous temp variable to get around it,
> something like:
> my $quoted= $dbh->quote( ${ \$hash->{'some'} } );
That didn't work, see above.
> DBI has been used so often, by so many, that if there's a bug in the
> quoting function when using tied variables, i'd expect it's been discovered
> and fixed already. but it's probably worth it to have a look at the source
> for quote, as phil suggested.
I would have thought so too, which is why this surprised me and I assumed it
was something I was doing wrong.
I finally found searchterms that turned up something useful on google:
http://perlmonks.thepen.com/11965.html which confirms the tied hash issue. (It
is dated May 2000... I'd have thought someone would have solved it by now).
-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|