On Wed May 16 06:43:12 2012, jkramer wrote:
Show quoted text> Instead of always returning undef, it would be helpful to return a value
> that at least indicates whether the INSERT succeeded or not. Even better
> would be to somehow make the value configurable for the user, maybe
> using an anonymous function, so I could for example override the default
> behavior by giving 'insert_return => sub { return
> $_[0]->dbh->last_insert_id }' or something like that to the constructor.
thanks again!
It actually returns 'undef' in case of success ( $stm->rows() != 0),
and 0 in case of error (I know...).
The customizable return value sounds ok.
The insert_return function will receive the statement return, and the
default insert_return will be:
//
sub insert_return {
my ($selt, $statement) = @_;
return 0 if ($statement->rows() || 0) == -1;
return wantarray
? ($statement->{mysql_insertid}, $statement->rows() )
: $statement->{mysql_insertid}
;
}
//
Does it make sense to you?