単純な選択SQLクエリで問題が発生しました。php PDOを使用しています。
何らかの理由で、rowcount は 1 を返しますが、fetch と fetchall は両方とも false を返します。私にとっては、実行が失敗したか、クエリが行数が0になる結果を返さなかったことを意味します。私が知る限り、私のSQL構文は問題ありません。
ここにSQLクエリがあります
SELECT * FROM CustomerAddress WHERE ".CustomerAddress::custAddressID." = :".CustomerAddress::custAddressID." LIMIT 1
これがコードです。
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());
}