File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ protected function makeConfig(array $config) : array
121121 'password ' => null ,
122122 'schema ' => null ,
123123 'socket ' => null ,
124+ 'persistent ' => false ,
124125 'engine ' => 'InnoDB ' ,
125126 'charset ' => 'utf8mb4 ' ,
126127 'collation ' => 'utf8mb4_general_ci ' ,
@@ -196,7 +197,7 @@ protected function connect(
196197 }
197198 }
198199 $ this ->mysqli ->real_connect (
199- $ config ['host ' ],
200+ ( $ config [ ' persistent ' ] ? ' p: ' : '' ) . $ config ['host ' ],
200201 $ config ['username ' ],
201202 $ config ['password ' ],
202203 $ config ['schema ' ],
Original file line number Diff line number Diff line change @@ -55,6 +55,19 @@ public function testConnectionWithArray() : void
5555 self ::assertInstanceOf (Database::class, $ database );
5656 }
5757
58+ public function testPersistentConnection () : void
59+ {
60+ $ database = new Database ([
61+ 'username ' => \getenv ('DB_USERNAME ' ),
62+ 'password ' => \getenv ('DB_PASSWORD ' ),
63+ 'schema ' => \getenv ('DB_SCHEMA ' ),
64+ 'host ' => \getenv ('DB_HOST ' ),
65+ 'port ' => \getenv ('DB_PORT ' ),
66+ 'persistent ' => true ,
67+ ]);
68+ self ::assertInstanceOf (Database::class, $ database );
69+ }
70+
5871 public function testConnectionFail () : void
5972 {
6073 $ this ->expectException (mysqli_sql_exception::class);
You can’t perform that action at this time.
0 commit comments