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

  • SEARCH
  • Home
  • 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 1045779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:02:20+00:00 2026-05-16T16:02:20+00:00

i ave been having trouble with a simple select sql query. using php PDO.

  • 0

i ave been having trouble with a simple select sql query.
using php PDO.

for some reason the rowcount returns 1 but fetch and fetchall both return false;
to me that means the execute failed or the query returned no results which would have a rowcount of 0. my sql syntax as far as i can tell is fine.

here is the sql query

SELECT * FROM CustomerAddress WHERE ".CustomerAddress::custAddressID." = :".CustomerAddress::custAddressID." LIMIT 1

here is the code.

try{
        if($this->selectCustomerAddressStatement->execute(array(CustomerAddress::custAddressID => $addressID)))
        {
            if($this->selectCustomerAddressStatement->rowCount() == 1)
            {   
                $this->selectCustomerAddressStatement->closeCursor();
                if($temp = $this->selectCustomerAddressStatement->fetch())
                {
                    $customerAddress = new CustomerAddress($temp);
                    if($customerAddress->getCustAddressID() == $addressID)
                    {
                        return $customerAddress;
                    }else{
                        throw new Exception("The Customer Address Retrieved was not what was Asked.");
                    }
                }else{
                    throw new Exception("Failed to retrieve Result set.");
                }
            }else{
                throw new Exception("Statement Returned To Many Results.");
            }
        }else{
            throw new Exception("Failed to Execute Statement.");
        }
    }catch(Exception $e) {
        $this->selectCustomerAddressStatement->closeCursor();
        throw new Exception("Customers:: selectCustomerAddress - ".$e->getMessage());
    }
  • 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-05-16T16:02:21+00:00Added an answer on May 16, 2026 at 4:02 pm

    Looks like the problem is:

    $this->selectCustomerAddressStatement->closeCursor();
    

    .. which is being called after the row count. Closing the cursor probably releases the results of the statement which is why fetching returns nothing. Move that call to the end when you’re done with fetching the data.

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

Sidebar

Related Questions

ih ave read about the technique to allow dynamic HTML stylesheets using PHP's preprocessor,
I have an error in my query sub query. I been trying to work
I have a simple customers table designed this way (I report only some fields,
I'm writing a simple script, that fetches the details of some packages from the
This is how the query looks like: (simplified) SELECT * FROM posts WHERE user='37'
Pretty simple thing to do and I can't figure this one out for some
i'v got a problem with the Report Viewer form .NET 2008. I'ave to get
I am returned the following: <links> <image_link>http://img357.imageshack.us/img357/9606/48444016.jpg</image_link> <thumb_link>http://img357.imageshack.us/img357/9606/48444016.th.jpg</thumb_link> <ad_link>http://img357.imageshack.us/my.php?image=48444016.jpg</ad_link> <thumb_exists>yes</thumb_exists> <total_raters>0</total_raters> <ave_rating>0.0</ave_rating> <image_location>img357/9606/48444016.jpg</image_location> <thumb_location>img357/9606/48444016.th.jpg</thumb_location>
I have been reading over a lot of questions, but cant seem to find
I have a PHP script that generates a list of places and I need

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.