errorCode() 及 errorInfo()
errorCode():
$sth = $dbh->prepare('select * from product where id = :id');
$sth->bindParam(':id',$_POST['id']);
$sth->execute();
if ($sth->errorCode())
{
echo "恩丟唷~";
print_r($sth->errorInfo());
}
errorInfo():
$sth->errorInfo是一個陣列,有三個索引值分別對應不同訊息
0->SQLSTATE error code
1->返回Drier的錯誤碼
2->返回Driver的錯誤訊息
沒有留言:
張貼留言