ajustes das instâncias
This commit is contained in:
@@ -17,7 +17,7 @@ class Controller extends DBA{
|
||||
public function getLogin($NO_USERNAME){
|
||||
if(!$NO_USERNAME==''){
|
||||
$this->sql = "SELECT * FROM LOGIN WHERE NO_USERNAME = ?";
|
||||
$this->stmt = self::$inst->prepare($this->sql);
|
||||
$this->stmt = self::$instFIRE->prepare($this->sql);
|
||||
$this->stmt->bindValue(1,$NO_USERNAME);
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetch(PDO::FETCH_OBJ);
|
||||
@@ -31,7 +31,7 @@ class Controller extends DBA{
|
||||
//CRIADO PARA TESTE COM PARAMETRO
|
||||
if(!$NOME==''){
|
||||
$this->sql = "SELECT * FROM ALUNO WHERE NO_ALUNO LIKE ?";
|
||||
$this->stmt = self::$inst->prepare($this->sql);
|
||||
$this->stmt = self::$instFIRE->prepare($this->sql);
|
||||
$this->stmt->bindValue(1,"%".$NOME."%");
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
@@ -50,7 +50,7 @@ class Controller extends DBA{
|
||||
}
|
||||
public function getPais(){
|
||||
$this->sql = "SELECT * FROM usuarios";
|
||||
$this->stmt = self::$inst1->prepare($this->sql);
|
||||
$this->stmt = self::$instMARIA->prepare($this->sql);
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $this-> res;
|
||||
@@ -59,22 +59,29 @@ class Controller extends DBA{
|
||||
|
||||
class DBA{
|
||||
protected $stmt, $sql, $res;
|
||||
protected static $inst;
|
||||
protected static $inst1;
|
||||
protected static $instFIRE;
|
||||
protected static $instMARIA;
|
||||
//faz a chamada da instancia da conexão com o banco de dados
|
||||
function __construct(){
|
||||
try{
|
||||
if(self::$inst === null){
|
||||
//FIREBIRD
|
||||
self::$inst = new \PDO(STR_BD,USUARIO,SENHA);
|
||||
//MARIADB
|
||||
self::$inst1 = new \PDO(DB_CONTROLE,USER,PASS);
|
||||
if(self::$instFIRE === null){
|
||||
self::$instFIRE = new \PDO(STR_BD,USUARIO,SENHA);
|
||||
}
|
||||
//retorna a instancia com sucesso
|
||||
//echo "Connected successfully";
|
||||
}catch(\PDOException $e){
|
||||
}catch(\PDOException $e){
|
||||
//retorna caso de erro na conexão
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
try{
|
||||
if(self::$instMARIA === null){
|
||||
self::$instMARIA = new \PDO(DB_CONTROLE,USER,PASS);
|
||||
}
|
||||
//retorna a instancia com sucesso
|
||||
//echo "Connected successfully";
|
||||
}catch(\PDOException $e){
|
||||
//retorna caso de erro na conexão
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user