Skip to content

Commit

Permalink
[Hotfix] Stop PDO call (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuplaboom authored May 10, 2023
1 parent ab0f073 commit c32fded
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/Synchronization/Executor/DataTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ class DataTransfer implements DataTransferInterface
* where ids are those already inserted for the given table.
*/
protected array $tableIdInserted = [];
protected PDOConnectionInterface $distantPDOConnection;
protected PDOConnectionInterface $localPDOConnection;

public function __construct(ConfigurationProviderInterface $configurationProvider, PDOConnectionInterface $distantPDOConnection, PDOConnectionInterface $localPDOConnection, SqlBuilder $sqlBuilder)
{
$this->dbDistant = $distantPDOConnection->getPDO();
$this->dbLocale = $localPDOConnection->getPDO();
$this->configurationProvider = $configurationProvider;
$this->sqlBuilder = $sqlBuilder;
$this->distantPDOConnection = $distantPDOConnection;
$this->localPDOConnection = $localPDOConnection;
}

public function fromDistantToLocal(array $tableModels): void
{
$this->dbLocale = $this->localPDOConnection->getPDO();
$this->dbDistant = $this->distantPDOConnection->getPDO();
$this->tableModels = $tableModels;
$this->removeDisabledTables();
$this->fillCurrentTableReferenced();
Expand Down
4 changes: 3 additions & 1 deletion src/Synchronization/Executor/SqlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ class SqlBuilder
protected ConfigurationProviderInterface $configurationProvider;
protected \PDO $dbLocale;
protected array $tableModels = [];
protected PDOConnectionInterface $localPDOConnection;

public function __construct(ConfigurationProviderInterface $configurationProvider, PDOConnectionInterface $localPDOConnection)
{
$this->configurationProvider = $configurationProvider;
$this->dbLocale = $localPDOConnection->getPDO();
$this->localPDOConnection = $localPDOConnection;
}

public function selectQuery(array $tableModels, string $tableName, array $columns, array $forceIds = [], array $exceptsIds = []): string
{
$this->dbLocale = $this->localPDOConnection->getPDO();
$this->tableModels = $tableModels;
$andWhere = $this->getWhere($tableName, $forceIds);

Expand Down
8 changes: 6 additions & 2 deletions src/Synchronization/Provider/TableModelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ class TableModelProvider implements TableModelProviderInterface, OutputAwareInte
protected \PDO $dbLocale;
protected \PDO $dbDistant;
protected ConfigurationProviderInterface $configurationProvider;
protected PDOConnectionInterface $distantPDOConnection;
protected PDOConnectionInterface $localPDOConnection;

public function __construct(ConfigurationProviderInterface $configurationProvider, PDOConnectionInterface $distantPDOConnection, PDOConnectionInterface $localPDOConnection)
{
$this->configurationProvider = $configurationProvider;
$this->dbLocale = $localPDOConnection->getPDO();
$this->dbDistant = $distantPDOConnection->getPDO();
$this->distantPDOConnection = $distantPDOConnection;
$this->localPDOConnection = $localPDOConnection;
}

public function provideAll(): array
{
$this->dbLocale = $this->localPDOConnection->getPDO();
$this->dbDistant = $this->distantPDOConnection->getPDO();
$this->writeln("-----------------------------------");
$this->writeln("Generation of Tables Models started");
$this->writeln("-----------------------------------");
Expand Down

0 comments on commit c32fded

Please sign in to comment.