Skip to content

Commit 68e8211

Browse files
committed
Expose reconnect
1 parent e59e6e0 commit 68e8211

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

src/Database/Adapter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ protected function trigger(string $event, mixed $query): mixed
390390
*/
391391
abstract public function ping(): bool;
392392

393+
/**
394+
* Reconnect Database
395+
*/
396+
abstract public function reconnect(): void;
397+
393398
/**
394399
* Create Database
395400
*
@@ -904,6 +909,8 @@ abstract public function getSupportForUpserts(): bool;
904909
*/
905910
abstract public function getSupportForCacheSkipOnFailure(): bool;
906911

912+
abstract public function getSupportForReconnection(): bool;
913+
907914
/**
908915
* Get current attribute count from collection document
909916
*

src/Database/Adapter/Mongo.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public function ping(): bool
100100
return $this->getClient()->query(['ping' => 1])->ok ?? false;
101101
}
102102

103+
public function reconnect(): void
104+
{
105+
$this->client->connect();
106+
}
107+
103108
/**
104109
* Create Database
105110
*
@@ -1843,6 +1848,11 @@ public function getSupportForUpserts(): bool
18431848
return false;
18441849
}
18451850

1851+
public function getSupportForReconnection(): bool
1852+
{
1853+
return false;
1854+
}
1855+
18461856
/**
18471857
* Get current attribute count from collection document
18481858
*

src/Database/Adapter/SQL.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public function ping(): bool
132132
->execute();
133133
}
134134

135+
public function reconnect(): void
136+
{
137+
$this->getPDO()->reconnect();
138+
}
139+
135140
/**
136141
* Check if Database exists
137142
* Optionally check if collection exists in Database
@@ -881,6 +886,11 @@ public function getSupportForRelationships(): bool
881886
return true;
882887
}
883888

889+
public function getSupportForReconnection(): bool
890+
{
891+
return true;
892+
}
893+
884894
/**
885895
* @param mixed $stmt
886896
* @param Query $query
@@ -1155,7 +1165,7 @@ public function getSQLConditions(array $queries = [], string $separator = 'AND')
11551165
}
11561166
}
11571167

1158-
$tmp = implode(' '. $separator .' ', $conditions);
1168+
$tmp = implode(' ' . $separator . ' ', $conditions);
11591169
return empty($tmp) ? '' : '(' . $tmp . ')';
11601170
}
11611171

src/Database/Database.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,11 @@ public function ping(): bool
10721072
return $this->adapter->ping();
10731073
}
10741074

1075+
public function reconnect(): void
1076+
{
1077+
$this->adapter->reconnect();
1078+
}
1079+
10751080
/**
10761081
* Create the database
10771082
*

0 commit comments

Comments
 (0)