correção query aluno
This commit is contained in:
15
app/controllers/AlunoController.php
Normal file
15
app/controllers/AlunoController.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user