PHP PDO fetch error. rowcount = 1 but fetchall returns false;

carverotram

New Member
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\[code\]SELECT * FROM CustomerAddress WHERE ".CustomerAddress::custAddressID." = :".CustomerAddress::custAddressID." LIMIT 1\[/code\]here is the code.\[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()); }\[/code\]
 
Back
Top