File tree Expand file tree Collapse file tree 2 files changed +53
-7
lines changed
test/integration/Adapter/Driver/Pdo/Mysql Expand file tree Collapse file tree 2 files changed +53
-7
lines changed Original file line number Diff line number Diff line change @@ -177,18 +177,17 @@ public function query(
177
177
}
178
178
179
179
if ($ mode === self ::QUERY_MODE_PREPARE ) {
180
- $ this ->lastPreparedStatement = null ;
181
- $ this ->lastPreparedStatement = $ this ->driver ->createStatement ($ sql );
182
- $ this ->lastPreparedStatement ->prepare ();
180
+ $ lastPreparedStatement = $ this ->driver ->createStatement ($ sql );
181
+ $ lastPreparedStatement ->prepare ();
183
182
if (is_array ($ parameters ) || $ parameters instanceof ParameterContainer) {
184
183
if (is_array ($ parameters )) {
185
- $ this -> lastPreparedStatement ->setParameterContainer (new ParameterContainer ($ parameters ));
184
+ $ lastPreparedStatement ->setParameterContainer (new ParameterContainer ($ parameters ));
186
185
} else {
187
- $ this -> lastPreparedStatement ->setParameterContainer ($ parameters );
186
+ $ lastPreparedStatement ->setParameterContainer ($ parameters );
188
187
}
189
- $ result = $ this -> lastPreparedStatement ->execute ();
188
+ $ result = $ lastPreparedStatement ->execute ();
190
189
} else {
191
- return $ this -> lastPreparedStatement ;
190
+ return $ lastPreparedStatement ;
192
191
}
193
192
} else {
194
193
$ result = $ this ->driver ->getConnection ()->execute ($ sql );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace LaminasIntegrationTest \Db \Adapter \Driver \Pdo \Mysql ;
4
+
5
+ use Laminas \Db \TableGateway \TableGateway ;
6
+ use PHPUnit \Framework \TestCase ;
7
+
8
+ use function array_fill ;
9
+
10
+ /**
11
+ * Usually mysql has 151 max connections by default.
12
+ * Set up a test where executed Laminas\Db\Adapter\Adapter::query and then using table gateway to fetch a row
13
+ * On tear down disconnected from the database and set the driver adapter on null
14
+ * Running many tests ended up in consuming all mysql connections and not releasing them
15
+ */
16
+ class TableGatewayAndAdapterTest extends TestCase
17
+ {
18
+ use AdapterTrait;
19
+
20
+ /**
21
+ * @dataProvider connections
22
+ */
23
+ public function testGetOutOfConnections (): void
24
+ {
25
+ $ this ->adapter ->query ('SELECT VERSION(); ' );
26
+ $ table = new TableGateway (
27
+ 'test ' ,
28
+ $ this ->adapter
29
+ );
30
+ $ select = $ table ->getSql ()->select ()->where (['name ' => 'foo ' ]);
31
+ $ result = $ table ->selectWith ($ select );
32
+ self ::assertCount (3 , $ result ->current ());
33
+ }
34
+
35
+ protected function tearDown (): void
36
+ {
37
+ if ($ this ->adapter ->getDriver ()->getConnection ()->isConnected ()) {
38
+ $ this ->adapter ->getDriver ()->getConnection ()->disconnect ();
39
+ }
40
+ $ this ->adapter = null ;
41
+ }
42
+
43
+ public function connections (): array
44
+ {
45
+ return array_fill (0 , 200 , []);
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments