概述
我一直遇到一个简单的选择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());
}
最后
以上就是虚幻台灯为你收集整理的php pdo获取错误信息,PHP PDO获取错误 . rowcount = 1但fetchall返回false;的全部内容,希望文章能够帮你解决php pdo获取错误信息,PHP PDO获取错误 . rowcount = 1但fetchall返回false;所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复