我應該如何準備代碼,如果它失敗了?用try-catch語句或?PHP和Postgres:捕獲錯誤?
function delete_question ($question_id) {
$dbconn = pg_connect("host=localhost port=5432 dbname=heoa user=heoa password=123");
// removes questions and its dependencies: answers and tags
$result = pg_query_params ($dbconn,
'DELETE FROM questions
WHERE question_id = $1',
array ($question_id)
);
你的意思是我能趕上pg_last_error沒有明確的投語句? – hhh 2009-09-03 19:12:57
關於該功能的更多信息:http://us.php.net/manual/en/function.pg-last-error.php – hhh 2009-09-03 19:13:31
您可以隨時將自己的例外包裝到pg_ *函數中。 – 2009-09-03 19:13:40