Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:37:33+00:00 2026-06-07T23:37:33+00:00

The doc for error handling for fetch() seems unclear and I haven’t found an

  • 0

The doc for error handling for fetch() seems unclear and I haven’t found an answer anywhere after a lot of searching. A common usage model for fetch as shown in the doc is:

while ( $row = $stmt->fetch() ) {
    // do something with $row
}

The PHP doc at http://www.php.net/manual/en/pdostatement.fetch.php says:

In all cases, FALSE is returned on failure.

What does “failure” mean? An error? A failure to fetch more rows? My question is: when fetch() returns FALSE, what is best practice to detect errors? It seems like after the loop I need to distinguish between an error case and the “no more rows” case.

Should I call $stmt->errorCode() and see if it’s ‘00000’ ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:37:36+00:00Added an answer on June 7, 2026 at 11:37 pm

    fetch() will return false when there’s no more data to be fetched. There could also be other case where there truly is a failure, e.g. mysql died or the connection was lost while doing the fetch loop. But generally speaking, that sort of “real” failure is fairly rare, and you’ll most often get “false because there’s no more data available”.

    If you’re truly paranoid about writing error handling, then by all means, put an sql error code check after the while loop to catch the cases when something really did blow up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After uncommenting this line url(r'^admin/doc/', include('django.contrib.admindocs.urls')), I am getting template error.
Using the guide http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html i'm trying to customize error message, but i've a problem:
I'm using the following: el = doc.createElement(input); el.size = 2%; I get the error
the variable doc is not accessible anywhere else in the method outside of the
nodes = [doc nodesForXPath:@//user error: nil]; for (CXMLElement *node in nodes) { [itemPreDict setObject:[[node
I'm getting this error with following line: Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(html.toString()))); Details:
I am having a problem in using Raphaël library. Im getting following error 'R._g.doc.body'
HOw to Solve this? Any Help? ERROR : java.net.MalformedURLException: Protocol not found: /mnt/sdcard/EREADER/NewForestPonies/OEBPS/content.opf Code:
According to the doc, the 'error' ajax event gets passed the XMLHttpRequest object, 'success'
Problem is that i do all according this topic http://www.yiiframework.com/doc/guide/1.1/en/topics.error , but when in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.