File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,13 @@ class Connection implements ConnectionInterface
161
161
*/
162
162
protected static $ resolvers = [];
163
163
164
+ /**
165
+ * The type of the connection.
166
+ *
167
+ * @var string|null
168
+ */
169
+ protected $ type ;
170
+
164
171
/**
165
172
* Create a new database connection instance.
166
173
*
@@ -1045,6 +1052,16 @@ public function getName()
1045
1052
return $ this ->getConfig ('name ' );
1046
1053
}
1047
1054
1055
+ /**
1056
+ * Get the database connection full name.
1057
+ *
1058
+ * @return string|null
1059
+ */
1060
+ public function getFullName ()
1061
+ {
1062
+ return $ this ->getName ().($ this ->type ? ':: ' .$ this ->type : '' );
1063
+ }
1064
+
1048
1065
/**
1049
1066
* Get an option from the configuration options.
1050
1067
*
@@ -1274,6 +1291,19 @@ public function setDatabaseName($database)
1274
1291
return $ this ;
1275
1292
}
1276
1293
1294
+ /**
1295
+ * Set the type of the connection.
1296
+ *
1297
+ * @param string $type
1298
+ * @return $this
1299
+ */
1300
+ public function setType ($ type )
1301
+ {
1302
+ $ this ->type = $ type ;
1303
+
1304
+ return $ this ;
1305
+ }
1306
+
1277
1307
/**
1278
1308
* Get the table prefix for the connection.
1279
1309
*
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public function __construct($app, ConnectionFactory $factory)
62
62
$ this ->factory = $ factory ;
63
63
64
64
$ this ->reconnector = function ($ connection ) {
65
- $ this ->reconnect ($ connection ->getName ());
65
+ $ this ->reconnect ($ connection ->getFullName ());
66
66
};
67
67
}
68
68
@@ -165,7 +165,7 @@ protected function configuration($name)
165
165
*/
166
166
protected function configure (Connection $ connection , $ type )
167
167
{
168
- $ connection = $ this ->setPdoForType ($ connection , $ type );
168
+ $ connection = $ this ->setPdoForType ($ connection , $ type )-> setType ( $ type ) ;
169
169
170
170
// First we'll set the fetch mode and a few other dependencies of the database
171
171
// connection. This method basically just configures and prepares it to get
@@ -275,7 +275,11 @@ public function usingConnection($name, callable $callback)
275
275
*/
276
276
protected function refreshPdoConnections ($ name )
277
277
{
278
- $ fresh = $ this ->makeConnection ($ name );
278
+ [$ database , $ type ] = $ this ->parseConnectionName ($ name );
279
+
280
+ $ fresh = $ this ->configure (
281
+ $ this ->makeConnection ($ database ), $ type
282
+ );
279
283
280
284
return $ this ->connections [$ name ]
281
285
->setPdo ($ fresh ->getRawPdo ())
You can’t perform that action at this time.
0 commit comments