rotas nomeadas corrigidas

This commit is contained in:
Reginaldo
2023-06-14 11:29:53 -03:00
parent 00d21cc8c5
commit 38cbb4dc8c
10 changed files with 64 additions and 20 deletions

View File

@@ -1,8 +1,8 @@
<?php
namespace app\controllers;
use League\Plates\Engine;
class Controller{
use PDO;
class Controller extends DBA{
public static function view(string $view, array $data = []){
$viewsPath = dirname(__FILE__,2)."/views";
@@ -13,5 +13,37 @@ class Controller{
$templates = new Engine($viewsPath);
echo $templates-> render($view,$data);
}
}
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->bindValue(1,$NO_USERNAME);
$this->stmt->execute();
$this->res = $this->stmt->fetch(PDO::FETCH_OBJ);
return $this-> res;
}else{
//caso o id não foi passado recebe essa mensagem
die('informação incompleta...');
}
}
}
class DBA{
protected $stmt, $sql, $res;
protected static $inst;
//faz a chamada da instancia da conexão com o banco de dados
function __construct(){
try{
if(self::$inst === null){
self::$inst = new \PDO(STR_BD,USUARIO,SENHA);
}
//retorna a instancia com sucesso
//echo "Connected successfully";
return self::$inst;
}catch(\PDOException $e){
//retorna caso de erro na conexão
echo "Connection failed: " . $e->getMessage();
}
}
}