
SQLite3::enableExceptions를 호출하여 예외 처리를 활성화한 후, SQLite3::lastError 메서드를 호출하여 오류 메시지를 확인하는 방법은 다음과 같습니다.
1. SQLite3::enableExceptions를 호출하여 예외 처리를 활성화합니다.
#hostingforum.kr
php
$db = new SQLite3('example.db');
$db->enableExceptions(true);
2. SQLite3::lastError 메서드를 호출하여 오류 메시지를 확인합니다.
#hostingforum.kr
php
try {
// 데이터베이스 연산을 수행합니다.
$db->exec('SELECT * FROM non_existent_table');
} catch (Exception $e) {
// 오류 메시지를 확인합니다.
$error = $db->lastError();
echo "오류 메시지: $errorn";
}
이러한 방법으로, SQLite3::enableExceptions를 호출하여 예외 처리를 활성화한 후, SQLite3::lastError 메서드를 호출하여 오류 메시지를 확인할 수 있습니다.
2025-06-14 03:39