看板 PHP 關於我們 聯絡資訊
function NewSqlGo($SqlLink=NULL,$Parameters=NULL){ try{ $sth = $this->dbh->prepare($SqlLink); $sth->execute($Parameters); //print_r($sth->errorInfo()); //這裡可以輸出錯誤 } catch (PDOException $e) { /*連線例外方法 ===========================*/ echo "例外"; print_r( $e->errorInfo()); } //$this->dbh =NULL;//關閉連線 } 這是我寫的一個連線方法 在最上面已經有產生資料庫連線 然而我故意傳入一個錯誤的資料庫 然而只有在TRY 那邊使用 $sth->errorInfo() 才會顯現錯誤語法~ 然後在例外處理部分使用$e去接 並把它導向errorInfo()要列印出錯誤 結果 不管是echo "例外" 或者 $e->errorInfo() 都沒有顯現資料 各位大大有誰可以為我解惑嗎?~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 202.39.212.171
tonytsai88:$e is a Exception instance, not a PDO statement 11/13 23:20
tonytsai88:instance 11/13 23:20