3
3
namespace Squirrel \Queries \Doctrine ;
4
4
5
5
use Doctrine \DBAL \Connection ;
6
- use Doctrine \DBAL \FetchMode ;
7
6
use Squirrel \Debug \Debug ;
8
7
use Squirrel \Queries \DBInterface ;
9
8
use Squirrel \Queries \DBRawInterface ;
@@ -76,10 +75,10 @@ public function select($query, array $vars = []): DBSelectQueryInterface
76
75
77
76
// Prepare and execute query
78
77
$ statement = $ this ->connection ->prepare ($ query );
79
- $ statement ->execute ($ vars );
78
+ $ statementResult = $ statement ->execute ($ vars );
80
79
81
80
// Return select query object with PDO statement
82
- return new DBSelectQuery ($ statement );
81
+ return new DBSelectQuery ($ statementResult );
83
82
}
84
83
85
84
public function fetch (DBSelectQueryInterface $ selectQuery ): ?array
@@ -94,7 +93,7 @@ public function fetch(DBSelectQueryInterface $selectQuery): ?array
94
93
}
95
94
96
95
// Get the result - can be an array of the entry, or false if it is empty
97
- $ result = $ selectQuery ->getStatement ()->fetch (FetchMode:: ASSOCIATIVE );
96
+ $ result = $ selectQuery ->getStatement ()->fetchAssociative ( );
98
97
99
98
// Return one result as an array
100
99
return ($ result === false ? null : $ result );
@@ -112,7 +111,7 @@ public function clear(DBSelectQueryInterface $selectQuery): void
112
111
}
113
112
114
113
// Close the result set
115
- $ selectQuery ->getStatement ()->closeCursor ();
114
+ $ selectQuery ->getStatement ()->free ();
116
115
}
117
116
118
117
public function fetchOne ($ query , array $ vars = []): ?array
@@ -135,11 +134,11 @@ public function fetchAll($query, array $vars = []): array
135
134
136
135
// Prepare and execute query
137
136
$ statement = $ this ->connection ->prepare ($ query );
138
- $ statement ->execute ($ vars );
137
+ $ statementResult = $ statement ->execute ($ vars );
139
138
140
139
// Get result and close result set
141
- $ result = $ statement -> fetchAll (FetchMode:: ASSOCIATIVE );
142
- $ statement -> closeCursor ();
140
+ $ result = $ statementResult -> fetchAllAssociative ( );
141
+ $ statementResult -> free ();
143
142
144
143
// Return query result
145
144
return $ result ;
@@ -188,8 +187,8 @@ public function insert(string $tableName, array $row = [], string $autoIncrement
188
187
($ columnValue instanceof LargeObject) ? \PDO ::PARAM_LOB : \PDO ::PARAM_STR ,
189
188
);
190
189
}
191
- $ statement ->execute ();
192
- $ statement -> closeCursor ();
190
+ $ statementResult = $ statement ->execute ();
191
+ $ statementResult -> free ();
193
192
194
193
// No autoincrement index - no insert ID return value needed
195
194
if (\strlen ($ autoIncrementIndex ) === 0 ) {
@@ -262,13 +261,13 @@ public function change(string $query, array $vars = []): int
262
261
($ columnValue instanceof LargeObject) ? \PDO ::PARAM_LOB : \PDO ::PARAM_STR ,
263
262
);
264
263
}
265
- $ statement ->execute ();
264
+ $ statementResult = $ statement ->execute ();
266
265
267
266
// Get affected rows
268
- $ result = $ statement ->rowCount ();
267
+ $ result = $ statementResult ->rowCount ();
269
268
270
269
// Close query
271
- $ statement -> closeCursor ();
270
+ $ statementResult -> free ();
272
271
273
272
// Return affected rows
274
273
return $ result ;
0 commit comments