を取った場合、私はちょうどこのコードを実行しようとしていた:PDOは、エラーを受け取り、
public function create_account($username, $password, $email) {
$password = sha1($password);
$activation_key = md5($username . $email);
$this->STH = $this->DBH->prepare("INSERT INTO users(username, password, email, activation_key, created) VALUES(:username, :password, :email, :activation_key, :created)");
$this->STH->bindParam(':username', $username);
$this->STH->bindParam(':password', $password);
$this->STH->bindParam(':email', $email);
$this->STH->bindParam(':activation_key', $activation_key);
$this->STH->bindParam(':created', time());
$this->STH->execute();
if ($this->DBH->lastInsertId()) {
//$this->send_mail($username, $email);
return true;
} else {
//Log
}
}
は、今では確かに、取り組んでいます。しかし、ちょうど1分前に、私はデータが挿入されていないことを導いたSQL文でa)を逃しました。私はtry {}キャッチブロックを試しました - しかし、私は何のエラーも受けていませんでした - それはそうだと思いますか? PDOエラー(受信した場合)を適切に記録するには、このコードを修正する方法を教えてください。
おそらく関連しています:[PDOからエラーメッセージを取り出す方法](http://stackoverflow.com/q/3726) 505) –