33namespace Squirrel \Queries \Doctrine ;
44
55use Doctrine \DBAL \Connection ;
6- use Doctrine \DBAL \FetchMode ;
76use Squirrel \Debug \Debug ;
87use Squirrel \Queries \DBInterface ;
98use Squirrel \Queries \DBRawInterface ;
@@ -76,10 +75,10 @@ public function select($query, array $vars = []): DBSelectQueryInterface
7675
7776 // Prepare and execute query
7877 $ statement = $ this ->connection ->prepare ($ query );
79- $ statement ->execute ($ vars );
78+ $ statementResult = $ statement ->execute ($ vars );
8079
8180 // Return select query object with PDO statement
82- return new DBSelectQuery ($ statement );
81+ return new DBSelectQuery ($ statementResult );
8382 }
8483
8584 public function fetch (DBSelectQueryInterface $ selectQuery ): ?array
@@ -94,7 +93,7 @@ public function fetch(DBSelectQueryInterface $selectQuery): ?array
9493 }
9594
9695 // 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 ( );
9897
9998 // Return one result as an array
10099 return ($ result === false ? null : $ result );
@@ -112,7 +111,7 @@ public function clear(DBSelectQueryInterface $selectQuery): void
112111 }
113112
114113 // Close the result set
115- $ selectQuery ->getStatement ()->closeCursor ();
114+ $ selectQuery ->getStatement ()->free ();
116115 }
117116
118117 public function fetchOne ($ query , array $ vars = []): ?array
@@ -135,11 +134,11 @@ public function fetchAll($query, array $vars = []): array
135134
136135 // Prepare and execute query
137136 $ statement = $ this ->connection ->prepare ($ query );
138- $ statement ->execute ($ vars );
137+ $ statementResult = $ statement ->execute ($ vars );
139138
140139 // Get result and close result set
141- $ result = $ statement -> fetchAll (FetchMode:: ASSOCIATIVE );
142- $ statement -> closeCursor ();
140+ $ result = $ statementResult -> fetchAllAssociative ( );
141+ $ statementResult -> free ();
143142
144143 // Return query result
145144 return $ result ;
@@ -188,8 +187,8 @@ public function insert(string $tableName, array $row = [], string $autoIncrement
188187 ($ columnValue instanceof LargeObject) ? \PDO ::PARAM_LOB : \PDO ::PARAM_STR ,
189188 );
190189 }
191- $ statement ->execute ();
192- $ statement -> closeCursor ();
190+ $ statementResult = $ statement ->execute ();
191+ $ statementResult -> free ();
193192
194193 // No autoincrement index - no insert ID return value needed
195194 if (\strlen ($ autoIncrementIndex ) === 0 ) {
@@ -262,13 +261,13 @@ public function change(string $query, array $vars = []): int
262261 ($ columnValue instanceof LargeObject) ? \PDO ::PARAM_LOB : \PDO ::PARAM_STR ,
263262 );
264263 }
265- $ statement ->execute ();
264+ $ statementResult = $ statement ->execute ();
266265
267266 // Get affected rows
268- $ result = $ statement ->rowCount ();
267+ $ result = $ statementResult ->rowCount ();
269268
270269 // Close query
271- $ statement -> closeCursor ();
270+ $ statementResult -> free ();
272271
273272 // Return affected rows
274273 return $ result ;
0 commit comments