Skip to content

Commit

Permalink
atualizacao angular 9
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobmorais committed Aug 24, 2022
1 parent 0a7f383 commit bd3f89b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/DatalayerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ trait DatalayerTrait
* @param $database
* @return PDO|null
*/
private function getInstance($database)
private function getInstance()
{
if (strpos($_SERVER['SERVER_NAME'],"homologacao") && !strpos($database,"homologacao") )
$database .= "Homologacao";
if (strpos($_SERVER['SERVER_NAME'],"homologacao") && !strpos($this->database,"homologacao") )
$this->database .= "Homologacao";

if (!isset($this->instance)) {
$this->instance = Connect::getInstance($database);
$this->instance = Connect::getInstance($this->database);
return $this->instance;
} else {
return $this->instance;
Expand All @@ -51,7 +51,7 @@ private function getInstance($database)
protected function executeSQL(String $query, ?array $params = null)
{
try {
$this->getInstance($this->database);
$this->getInstance();
$this->prepare = $this->instance->prepare($query);
$this->prepare->execute($params);
} catch (PDOException $e) {
Expand Down Expand Up @@ -187,7 +187,7 @@ protected function fetchOneClass($prepare=null, String $class=null)
protected function beginTrasaction()
{
try {
$this->getInstance($this->database);
$this->getInstance();
$this->instance->beginTransaction();
return true;
} catch (PDOException $e) {
Expand All @@ -202,7 +202,7 @@ protected function beginTrasaction()
*/
protected function commitTransaction(){
try {
$this->getInstance($this->database);
$this->getInstance();
$this->instance->commit();
return true;
} catch (PDOException $e) {
Expand All @@ -217,7 +217,7 @@ protected function commitTransaction(){
protected function rollBackTransaction(){

try {
$this->getInstance($this->database);
$this->getInstance();
$this->instance->rollBack();
return true;
} catch (PDOException $e) {
Expand All @@ -231,7 +231,7 @@ protected function rollBackTransaction(){
*/
private function lastId()
{
$this->getInstance($this->database);
$this->getInstance();
$ultimo = $this->instance->lastInsertId();
return $ultimo;

Expand All @@ -246,7 +246,7 @@ private function lastId()
protected function selectDB($sql, $params = null, $class = null)
{
try {
$this->getInstance($this->database);
$this->getInstance();
$this->prepare = $this->instance->prepare($sql);
$this->prepare->execute($params);

Expand All @@ -270,7 +270,7 @@ protected function selectDB($sql, $params = null, $class = null)
protected function insertDB($sql, $params = null)
{
try {
$this->getInstance($this->database);
$this->getInstance();
$this->prepare = $this->instance->prepare($sql);
$rs = $this->prepare->execute($params);
} catch (PDOException $e) {
Expand All @@ -288,7 +288,7 @@ protected function insertDB($sql, $params = null)
protected function updateDB($sql, $params = null)
{
try {
$this->getInstance($this->database);
$this->getInstance();
$query = $this->instance->prepare($sql);
$rs = $query->execute($params);
} catch (PDOException $e) {
Expand All @@ -306,7 +306,7 @@ protected function updateDB($sql, $params = null)
protected function deleteDB($sql, $params = null)
{
try {
$this->getInstance($this->database);;
$this->getInstance();;
$this->prepare = $this->instance->prepare($sql);
$rs = $this->prepare->execute($params);
} catch (PDOException $e) {
Expand Down

0 comments on commit bd3f89b

Please sign in to comment.