5
5
use Carbon \CarbonInterval ;
6
6
use Closure ;
7
7
use DateTimeInterface ;
8
- use Doctrine \DBAL \Connection as DoctrineConnection ;
9
- use Doctrine \DBAL \Types \Type ;
10
8
use Exception ;
11
9
use Illuminate \Contracts \Events \Dispatcher ;
12
10
use Illuminate \Database \Events \QueryExecuted ;
@@ -189,20 +187,6 @@ class Connection implements ConnectionInterface
189
187
*/
190
188
protected $ beforeExecutingCallbacks = [];
191
189
192
- /**
193
- * The instance of Doctrine connection.
194
- *
195
- * @var \Doctrine\DBAL\Connection
196
- */
197
- protected $ doctrineConnection ;
198
-
199
- /**
200
- * Type mappings that should be registered with new Doctrine connections.
201
- *
202
- * @var array<string, string>
203
- */
204
- protected $ doctrineTypeMappings = [];
205
-
206
190
/**
207
191
* The connection resolvers.
208
192
*
@@ -989,8 +973,6 @@ protected function tryAgainIfCausedByLostConnection(QueryException $e, $query, $
989
973
public function reconnect ()
990
974
{
991
975
if (is_callable ($ this ->reconnector )) {
992
- $ this ->doctrineConnection = null ;
993
-
994
976
return call_user_func ($ this ->reconnector , $ this );
995
977
}
996
978
@@ -1017,8 +999,6 @@ public function reconnectIfMissingConnection()
1017
999
public function disconnect ()
1018
1000
{
1019
1001
$ this ->setPdo (null )->setReadPdo (null );
1020
-
1021
- $ this ->doctrineConnection = null ;
1022
1002
}
1023
1003
1024
1004
/**
@@ -1208,106 +1188,6 @@ public function useWriteConnectionWhenReading($value = true)
1208
1188
return $ this ;
1209
1189
}
1210
1190
1211
- /**
1212
- * Is Doctrine available?
1213
- *
1214
- * @return bool
1215
- */
1216
- public function isDoctrineAvailable ()
1217
- {
1218
- return class_exists ('Doctrine\DBAL\Connection ' );
1219
- }
1220
-
1221
- /**
1222
- * Indicates whether native alter operations will be used when dropping, renaming, or modifying columns, even if Doctrine DBAL is installed.
1223
- *
1224
- * @return bool
1225
- */
1226
- public function usingNativeSchemaOperations ()
1227
- {
1228
- return ! $ this ->isDoctrineAvailable () || SchemaBuilder::$ alwaysUsesNativeSchemaOperationsIfPossible ;
1229
- }
1230
-
1231
- /**
1232
- * Get a Doctrine Schema Column instance.
1233
- *
1234
- * @param string $table
1235
- * @param string $column
1236
- * @return \Doctrine\DBAL\Schema\Column
1237
- */
1238
- public function getDoctrineColumn ($ table , $ column )
1239
- {
1240
- $ schema = $ this ->getDoctrineSchemaManager ();
1241
-
1242
- return $ schema ->introspectTable ($ table )->getColumn ($ column );
1243
- }
1244
-
1245
- /**
1246
- * Get the Doctrine DBAL schema manager for the connection.
1247
- *
1248
- * @return \Doctrine\DBAL\Schema\AbstractSchemaManager
1249
- */
1250
- public function getDoctrineSchemaManager ()
1251
- {
1252
- $ connection = $ this ->getDoctrineConnection ();
1253
-
1254
- return $ connection ->createSchemaManager ();
1255
- }
1256
-
1257
- /**
1258
- * Get the Doctrine DBAL database connection instance.
1259
- *
1260
- * @return \Doctrine\DBAL\Connection
1261
- */
1262
- public function getDoctrineConnection ()
1263
- {
1264
- if (is_null ($ this ->doctrineConnection )) {
1265
- $ driver = $ this ->getDoctrineDriver ();
1266
-
1267
- $ this ->doctrineConnection = new DoctrineConnection (array_filter ([
1268
- 'pdo ' => $ this ->getPdo (),
1269
- 'dbname ' => $ this ->getDatabaseName (),
1270
- 'driver ' => $ driver ->getName (),
1271
- 'serverVersion ' => $ this ->getConfig ('server_version ' ),
1272
- ]), $ driver );
1273
-
1274
- foreach ($ this ->doctrineTypeMappings as $ name => $ type ) {
1275
- $ this ->doctrineConnection
1276
- ->getDatabasePlatform ()
1277
- ->registerDoctrineTypeMapping ($ type , $ name );
1278
- }
1279
- }
1280
-
1281
- return $ this ->doctrineConnection ;
1282
- }
1283
-
1284
- /**
1285
- * Register a custom Doctrine mapping type.
1286
- *
1287
- * @param Type|class-string<Type> $class
1288
- * @param string $name
1289
- * @param string $type
1290
- * @return void
1291
- *
1292
- * @throws \Doctrine\DBAL\Exception
1293
- * @throws \RuntimeException
1294
- */
1295
- public function registerDoctrineType (Type |string $ class , string $ name , string $ type ): void
1296
- {
1297
- if (! $ this ->isDoctrineAvailable ()) {
1298
- throw new RuntimeException (
1299
- 'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal). '
1300
- );
1301
- }
1302
-
1303
- if (! Type::hasType ($ name )) {
1304
- Type::getTypeRegistry ()
1305
- ->register ($ name , is_string ($ class ) ? new $ class () : $ class );
1306
- }
1307
-
1308
- $ this ->doctrineTypeMappings [$ name ] = $ type ;
1309
- }
1310
-
1311
1191
/**
1312
1192
* Get the current PDO connection.
1313
1193
*
@@ -1722,6 +1602,16 @@ public function withTablePrefix(Grammar $grammar)
1722
1602
return $ grammar ;
1723
1603
}
1724
1604
1605
+ /**
1606
+ * Get the server version for the connection.
1607
+ *
1608
+ * @return string
1609
+ */
1610
+ public function getServerVersion (): string
1611
+ {
1612
+ return $ this ->getPdo ()->getAttribute (PDO ::ATTR_SERVER_VERSION );
1613
+ }
1614
+
1725
1615
/**
1726
1616
* Register a connection resolver.
1727
1617
*
0 commit comments