3
3
* @author Loic Mathaud
4
4
* @contributor Laurent Jouanneau
5
5
*
6
- * @copyright 2006 Loic Mathaud, 2008-2023 Laurent Jouanneau
6
+ * @copyright 2006 Loic Mathaud, 2008-2024 Laurent Jouanneau
7
7
*
8
8
* @see http://www.jelix.org
9
9
* @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
@@ -28,6 +28,11 @@ class ResultSet extends AbstractResultSet
28
28
*/
29
29
protected $ _idResult ;
30
30
31
+ /**
32
+ * @var Connection
33
+ */
34
+ protected $ _conn ;
35
+
31
36
/**
32
37
* number of rows.
33
38
*/
@@ -46,15 +51,16 @@ class ResultSet extends AbstractResultSet
46
51
*/
47
52
protected $ buffer = array ();
48
53
49
-
50
54
/**
51
- * @param \SQLite3Result $result
52
- * @param \SQLite3Stmt $stmt
55
+ * @param \SQLite3Result|null $result
56
+ * @param \SQLite3Stmt|null $stmt
57
+ * @param Connection
53
58
*/
54
- public function __construct ($ result , $ stmt = null )
59
+ public function __construct ($ result , $ stmt, $ conn )
55
60
{
56
61
parent ::__construct ($ result );
57
62
$ this ->_stmt = $ stmt ;
63
+ $ this ->_conn = $ conn ;
58
64
}
59
65
60
66
protected function _fetch ()
@@ -100,7 +106,12 @@ protected function _free()
100
106
$ this ->numRows = 0 ;
101
107
$ this ->buffer = array ();
102
108
$ this ->ended = false ;
103
- $ this ->_idResult ->finalize ();
109
+ // finalize may lead to an error if connection has been closed before
110
+ // the resultset object destruction.
111
+ if ($ this ->_conn && !$ this ->_conn ->isClosed ()) {
112
+ $ this ->_idResult ->finalize ();
113
+ }
114
+ $ this ->_conn = null ;
104
115
}
105
116
106
117
protected function _rewind ()
0 commit comments