我目前使用在我的項目下面的事情:PDO SQLSRV顯示錯誤 - 而露出的數據庫結構
- Symfony的2.3.11
- SQL Server 2008中
- 學說2(最新)+ PDO_SQLSRV(5.5)
- PHP 5.5.3
我做下面當我打電話$em->flush()
:
try {
$this->em->flush();
} catch (\PDOException $e) {
switch ($e->getCode() {
case /*Depending of the codes*/:
throw new \Exception(/*Message that hides the real error and just gives the code and a user-friendly message*/);
}
}
但是,此操作仍顯示任何SQL Server錯誤,向用戶公開查詢和內部結構。我應該怎麼做來捕捉這些錯誤並將它們轉換爲更好的消息?事先謝謝你。
指定symfony環境是指您指的是開發環境還是生產環境 –
這是生產環境,忘記提及了。 –
它可能會幫助你http://forum.symfony-project.org/viewtopic.php?f=23&t=70585 –