correção query aluno

This commit is contained in:
Reginaldo
2023-06-14 12:25:16 -03:00
parent 38cbb4dc8c
commit 92ca515d7e
4 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
<?php
namespace app\controllers;
class AlunoController{
public function index($params){
$numero = $params->NR_LOGRADOURO;
$Con = new Controller();
$Alunos = $Con->getAlunos($numero);
echo json_encode($Alunos);
return json_encode($Alunos);
}
public function store(){
var_dump('store do login');
}
}

View File

@@ -26,6 +26,27 @@ class Controller extends DBA{
//caso o id não foi passado recebe essa mensagem
die('informação incompleta...');
}
}
public function getAlunos($NR_LOGRADOURO){
//CRIADO PARA TESTE COM PARAMETRO
if(!$NR_LOGRADOURO==''){
$this->sql = "SELECT * FROM ALUNO WHERE NR_LOGRADOURO = ?";
$this->stmt = self::$inst->prepare($this->sql);
$this->stmt->bindValue(1,$NR_LOGRADOURO);
$this->stmt->execute();
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
return $this-> res;
}else{
//caso o id não foi passado recebe essa mensagem
die('informação incompleta...');
}
//FUNCIONANDO PARA TODA A TABELA ALUNO
//$this->sql = "SELECT * FROM ALUNO";
//$this->stmt = self::$inst->prepare($this->sql);
//$this->stmt -> execute();
//$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
//print_r($this->res);
//return $this->res;
}
}

View File

@@ -61,4 +61,7 @@ try{
//http://localhost:8000/?name=reginaldo
//dados do login
//http://localhost:8000/login?NO_USERNAME=AMENEZES
//http://localhost:8000/login?NO_USERNAME=AMENEZES
//dados alunos
//http://localhost:8000/aluno?NR_LOGRADOURO=715

View File

@@ -21,7 +21,8 @@ function load(string $controller, string $action){
$router= [
"GET"=>[
"/"=> fn()=> load("HomeController","index"),
"/login" => fn()=> load("LoginController","index")
"/login" => fn()=> load("LoginController","index"),
"/aluno" => fn()=> load("AlunoController","index")
],
"POST"=>[
"/login" => fn()=> load("LoginController","store")