Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Database/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ protected function trigger(string $event, mixed $query): mixed
*/
abstract public function ping(): bool;

/**
* Reconnect Database
*/
abstract public function reconnect(): void;

/**
* Create Database
*
Expand Down Expand Up @@ -904,6 +909,8 @@ abstract public function getSupportForUpserts(): bool;
*/
abstract public function getSupportForCacheSkipOnFailure(): bool;

abstract public function getSupportForReconnection(): bool;

/**
* Get current attribute count from collection document
*
Expand Down
10 changes: 10 additions & 0 deletions src/Database/Adapter/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public function ping(): bool
return $this->getClient()->query(['ping' => 1])->ok ?? false;
}

public function reconnect(): void
{
$this->client->connect();
}

/**
* Create Database
*
Expand Down Expand Up @@ -1843,6 +1848,11 @@ public function getSupportForUpserts(): bool
return false;
}

public function getSupportForReconnection(): bool
{
return false;
}

/**
* Get current attribute count from collection document
*
Expand Down
12 changes: 11 additions & 1 deletion src/Database/Adapter/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public function ping(): bool
->execute();
}

public function reconnect(): void
{
$this->getPDO()->reconnect();
}

/**
* Check if Database exists
* Optionally check if collection exists in Database
Expand Down Expand Up @@ -881,6 +886,11 @@ public function getSupportForRelationships(): bool
return true;
}

public function getSupportForReconnection(): bool
{
return true;
}

/**
* @param mixed $stmt
* @param Query $query
Expand Down Expand Up @@ -1155,7 +1165,7 @@ public function getSQLConditions(array $queries = [], string $separator = 'AND')
}
}

$tmp = implode(' '. $separator .' ', $conditions);
$tmp = implode(' ' . $separator . ' ', $conditions);
return empty($tmp) ? '' : '(' . $tmp . ')';
}

Expand Down
5 changes: 5 additions & 0 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,11 @@ public function ping(): bool
return $this->adapter->ping();
}

public function reconnect(): void
{
$this->adapter->reconnect();
}

/**
* Create the database
*
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -17734,9 +17734,13 @@ public function testEvents(): void
Database::EVENT_INDEX_DELETE,
Database::EVENT_DOCUMENT_PURGE,
Database::EVENT_DOCUMENT_DELETE,
Database::EVENT_DOCUMENT_PURGE,
Database::EVENT_DOCUMENT_PURGE,
Database::EVENT_DOCUMENTS_DELETE,
Database::EVENT_ATTRIBUTE_DELETE,
Database::EVENT_DOCUMENT_PURGE,
Database::EVENT_ATTRIBUTE_DELETE,
Database::EVENT_COLLECTION_DELETE,
Database::EVENT_DATABASE_DELETE,
Database::EVENT_DOCUMENT_PURGE,
Database::EVENT_DOCUMENTS_DELETE,
Database::EVENT_DOCUMENT_PURGE,
Expand Down
Loading