Skip to content

Commit

Permalink
correcao de bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Morais authored and Bruno Morais committed Nov 20, 2023
1 parent 7e5a2f4 commit 99a7ee1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/DatalayerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function setInstance(?PDO $pdo): self

protected function getInstance(): PDO
{
return $this->instance ?? $this->getConnect();
return $this->getConnect();
}

/**
Expand All @@ -114,8 +114,17 @@ protected function getInstance(): PDO
*/
protected function setDatabase(string $database): self
{
$this->database = $database;
$this->setInstance(null)->getInstance();
if (strpos($_SERVER['SERVER_NAME'], mb_strtolower(CONFIG_DATA_LAYER["homologation"])) && !strpos($database, ucfirst(CONFIG_DATA_LAYER["homologation"]))) {
$database = $database.ucfirst(CONFIG_DATA_LAYER["homologation"] ?? "");
$this->database = $database;
} else {
$this->database = $database;
}

if (!empty($this->instance)){
$this->executeSQL("USE {$this->getDatabase()}");
}

return $this;
}

Expand Down

0 comments on commit 99a7ee1

Please sign in to comment.