File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 15
15
16
16
use CodeIgniter \Database \BaseConnection ;
17
17
use CodeIgniter \Database \Exceptions \DatabaseException ;
18
- use ErrorException ;
19
18
use Exception ;
20
19
use SQLite3 ;
21
20
use SQLite3Result ;
@@ -87,9 +86,13 @@ public function connect(bool $persistent = false)
87
86
$ this ->database = WRITEPATH . $ this ->database ;
88
87
}
89
88
90
- return (! $ this ->password )
89
+ $ sqlite = (! $ this ->password )
91
90
? new SQLite3 ($ this ->database )
92
91
: new SQLite3 ($ this ->database , SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE , $ this ->password );
92
+
93
+ $ sqlite ->enableExceptions (true );
94
+
95
+ return $ sqlite ;
93
96
} catch (Exception $ e ) {
94
97
throw new DatabaseException ('SQLite3 error: ' . $ e ->getMessage ());
95
98
}
@@ -146,7 +149,7 @@ protected function execute(string $sql)
146
149
return $ this ->isWriteType ($ sql )
147
150
? $ this ->connID ->exec ($ sql )
148
151
: $ this ->connID ->query ($ sql );
149
- } catch (ErrorException $ e ) {
152
+ } catch (Exception $ e ) {
150
153
log_message ('error ' , (string ) $ e );
151
154
152
155
if ($ this ->DBDebug ) {
Original file line number Diff line number Diff line change 16
16
use BadMethodCallException ;
17
17
use CodeIgniter \Database \BasePreparedQuery ;
18
18
use CodeIgniter \Database \Exceptions \DatabaseException ;
19
+ use Exception ;
19
20
use SQLite3 ;
20
21
use SQLite3Result ;
21
22
use SQLite3Stmt ;
@@ -82,7 +83,15 @@ public function _execute(array $data): bool
82
83
$ this ->statement ->bindValue ($ key + 1 , $ item , $ bindType );
83
84
}
84
85
85
- $ this ->result = $ this ->statement ->execute ();
86
+ try {
87
+ $ this ->result = $ this ->statement ->execute ();
88
+ } catch (Exception $ e ) {
89
+ if ($ this ->db ->DBDebug ) {
90
+ throw new DatabaseException ($ e ->getMessage (), $ e ->getCode (), $ e );
91
+ }
92
+
93
+ return false ;
94
+ }
86
95
87
96
return $ this ->result !== false ;
88
97
}
You can’t perform that action at this time.
0 commit comments