File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
src/main/php/rdbms/sqlite3 Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ public function connect($reconnect= false) {
103103
104104 try {
105105 $ this ->handle = new SQLite3 ($ database , SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE );
106+ PHP_VERSION_ID >= 90000 || $ this ->handle ->enableExceptions (true );
106107 } catch (Exception $ e ) {
108+ $ this ->handle = false ;
107109 throw new SQLConnectException ($ e ->getMessage ().': ' .$ database , $ this ->dsn );
108110 }
109111
@@ -160,16 +162,17 @@ public function identity($field= null) {
160162 protected function query0 ($ sql , $ buffered = true ) {
161163 $ this ->handle instanceof SQLite3 || $ this ->connections ->establish ($ this );
162164
163- $ result = $ this ->handle ->query ($ sql );
164- if (false === $ result ) {
165- $ e = new SQLStatementFailedException (
165+ try {
166+ $ result = $ this ->handle ->query ($ sql );
167+ } catch (Exception $ e ) {
168+ throw new SQLStatementFailedException (
166169 'Statement failed: ' .$ this ->handle ->lastErrorMsg ().' @ ' .$ this ->dsn ->getDatabase (),
167170 $ sql ,
168171 $ this ->handle ->lastErrorCode ()
169172 );
170- \xp:: gc ( __FILE__ );
171- throw $ e ;
172- } else if ($ result ->numColumns ()) {
173+ }
174+
175+ if ($ result ->numColumns ()) {
173176 return new SQLite3ResultSet ($ result );
174177 } else {
175178 return new QuerySucceeded ($ this ->handle ->changes ());
You can’t perform that action at this time.
0 commit comments