load() should not depend on the value of $sth->rows() being greater than zero after a successful fetch() given the inconsistent behavior described in the DBI documentation:

   rows <http://search.cpan.org/%7Etimb/DBI/DBI.pm#___top>

   $rv = $sth->rows;

   Returns the number of rows affected by the last row affecting
   command, or -1 if the number of rows is not known or not available.

   Generally, you can only rely on a row count after a /non/-|SELECT|
   |execute| (for some specific operations like |UPDATE| and |DELETE|),
   or after fetching all the rows of a |SELECT| statement.

   For |SELECT| statements, it is generally not possible to know how
   many rows will be returned except by fetching them all. Some drivers
   will return the number of rows the application has fetched so far,
   but others may return -1 until all rows have been fetched. So use of
   the |rows| method or |$DBI::rows| with |SELECT| statements is not
   recommended.

Therefore, in Rose::DB::Object::load(),  the lines:

   my $r = $sth->fetch;
$rows = $sth->rows; $sth->finish;

should become something similar to:

   my $r = $sth->fetch;
   $rows = defined($r) ;
   $sth->finish;

Ideally, the implementation of sth->rows() would become standardized so that its value would be dependable one way or the other after a fetch().

Respectfully,
Philip Dye
Senior Research Systems Programmer
Computing Facilities Group
School of Computer Science
[EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to