2012-06-05 50 views
0

我想知道是否有可能輸出學說的錯誤,一個相當於是這樣的:學說查詢錯誤報告

模具(mysql_error());

我在問,因爲沒有保存數據,但沒有返回錯誤的表單腳本。我不知道教義在幕後做了什麼。

非常感謝 Ĵ

+0

如何使用[SQL Logger](http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/configuration.html#sql-logger-optional)? – manix

+0

哪個版本的教義? – j0k

回答

0
class FileSqlLogger implements Doctrine\DBAL\Logging\SQLLogger { 

    private $log_dir = '/var/www/logs/Doctrine/queries'; 

    public function startQuery($sql, array $params = null, array $types = null) 
    { 
     $now = new DateTime; 
     $file_name = "{$this->log_dir}/{$now->format('d-m-Y')}.log"; 

     if (is_writable($this->log_dir)) 
     { 
      file_put_contents($file_name, "{$now->format('H:i:s')}: Executing query '{$sql}' with parameters " . implode(', ', $params)); 
     } 
     else 
     { 
      die('Error: Unable to write to the Doctrine log file!'); 
     } 
    } 

} 

我沒有測試過這一點,我不知道是否會工作,但我認爲它應該幫助你在正確的方向。

0

Logging Doctrine錯誤。

也許可以提供幫助。