On Thu, Oct 23, 2003 at 10:19:01PM -0700, [EMAIL PROTECTED] wrote:
> Let's assume that the $sth->prepare() was good but something failed at
> this line:
>
> $sth = $dbh->exeute();
>
> if ($sth) is not consistent when connection or something goes bad.
After execute() a SELECT statement will leave $sth->{Active} true
if the execute was successful. That doesn't apply to non-select's though.
$sth->err and $sth->errstr will give the error details (until some
other method call clears them, as most do).
> Can you or someone comment further about testing $sth if there are rows?
It's not really clear what you are trying to achieve or, more
importantly, why you're trying to do it this way - being passed a
statement handle in an unknown state.
If you know the statement is a SELECT then if it's $sth->{Active}
you can try fetching from it.
Tim.
>
> -thanks
>
> > On Wed, 22 Oct 2003 22:18:18 -0700 (PDT) [EMAIL PROTECTED] wrote:
> >
> >> How can I test the status of $sth itself?
> >>
> >> A scenario is that a $sth is passed from a sub. And now, I have a
> >> $sth. Of course $sth->rows return 0 or whatever int row. However, a
> >> test using $sth->rows is not good when something is wrong. It return
> >> some large number. So How can I test to see if its bad or good
> >> without access to previous calls?
> >
> > If the $dbh->prepare() call failed, $sth will be false. The only
> > portable way to tell if $sth will return rows is to fetch some.
> >
> > --
> > Mac :})
> > ** I usually forward private questions to the appropriate mail list. **
> > Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html
> > Give a hobbit a fish and he eats fish for a day.
> > Give a hobbit a ring and he eats fish for an age.
> >
> >
>
>
>
> -----------------------------------------
> eMail solutions by
> http://www.swanmail.com
>