On Fri, Feb 14, 2003 at 11:05:19AM +0000, Tim Bunce wrote:
> Can you post an example script that calls selectrow_hashref and
> demonstrates the problem?

the application is written in HTML::Mason, so all the stuff for opening
the database, session management, etc is absent from this test script.

(it's not my application, and not really my script.  one of the
programmers complained that selectrow_hashref broke after the recent
upgrade to DBI 1.32.  simple queries like the following worked in DBI
1.30, but broke in 1.32.)



test2.html:
---cut here---
my $sql = "SELECT * FROM linksdb WHERE id = ?";

foreach my $link_id (2, 4, 5, 6, 100, 101, 120) {
  my $query_result = $dbh->selectrow_hashref($sql, undef, $link_id) ;

  warn "QR: '$query_result'";
  warn "QR->login: '" . $query_result->{login} . "'\n";
  warn "QR->name : '" . $query_result->{name} . "'\n";
  warn "QR->url  : '" . $query_result->{url} . "'\n";
  warn "QR->desc : '" . $query_result->{description} . "'\n";
};
---cut here---

link id numbers 2,4,5 & 6 exist in the database.  100, 101, and 120
don't.

all is fine until the script attempts to fetch the first non-existent
record (id 100).  when that happens, selectrow_hashref returns the
scalar "1" rather than a hashref.

[Fri Feb 14 11:39:40 2003] null: QR: '1' at /home/mc2/public_html/test/test2.html line 
6.

it then dies on line 7 with the attempt to dereference it.


craig

-- 
craig sanders <[EMAIL PROTECTED]>

Fabricati Diem, PVNC.
 -- motto of the Ankh-Morpork City Watch

Reply via email to