criação da conexão com o banco mobile
This commit is contained in:
@@ -5,5 +5,4 @@
|
||||
define('SENHA','K5f6rt9Y');
|
||||
define('BANCO','/bases/educa/iracemapolis/SISTEMA.FDB');
|
||||
define('STR_BD','firebird:dbname='.SERVIDOR.'/'.PORTA.':'.BANCO.';charset=UTF-8');
|
||||
|
||||
//será mudada depois o banco para a cidade desejada dinâmicamente
|
||||
@@ -3,9 +3,9 @@ namespace app\controllers;
|
||||
|
||||
class AlunoController{
|
||||
public function index($params){
|
||||
$numero = $params->NR_LOGRADOURO;
|
||||
$nome = $params->NOME;
|
||||
$Con = new Controller();
|
||||
$Alunos = $Con->getAlunos($numero);
|
||||
$Alunos = $Con->getAlunos($nome);
|
||||
echo json_encode($Alunos);
|
||||
return json_encode($Alunos);
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ class Controller extends DBA{
|
||||
die('informação incompleta...');
|
||||
}
|
||||
}
|
||||
public function getAlunos($NR_LOGRADOURO){
|
||||
public function getAlunos($NOME){
|
||||
//CRIADO PARA TESTE COM PARAMETRO
|
||||
if(!$NR_LOGRADOURO==''){
|
||||
$this->sql = "SELECT * FROM ALUNO WHERE NR_LOGRADOURO = ?";
|
||||
if(!$NOME==''){
|
||||
$this->sql = "SELECT * FROM ALUNO WHERE NO_ALUNO LIKE ?";
|
||||
$this->stmt = self::$inst->prepare($this->sql);
|
||||
$this->stmt->bindValue(1,$NR_LOGRADOURO);
|
||||
$this->stmt->bindValue(1,"%".$NOME."%");
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $this-> res;
|
||||
@@ -47,6 +47,13 @@ class Controller extends DBA{
|
||||
//$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//print_r($this->res);
|
||||
//return $this->res;
|
||||
}
|
||||
public function getPais(){
|
||||
$this->sql = "SELECT * FROM usuarios";
|
||||
$this->stmt = self::$inst->prepare($this->sql);
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $this-> res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +64,10 @@ class DBA{
|
||||
function __construct(){
|
||||
try{
|
||||
if(self::$inst === null){
|
||||
self::$inst = new \PDO(STR_BD,USUARIO,SENHA);
|
||||
//FIREBIRD
|
||||
//self::$inst = new \PDO(STR_BD,USUARIO,SENHA);
|
||||
//MARIADB
|
||||
self::$inst = new \PDO("mysql:dbname=controledb;host=localhost;charset=utf8",'root','');
|
||||
}
|
||||
//retorna a instancia com sucesso
|
||||
//echo "Connected successfully";
|
||||
|
||||
14
app/controllers/PaisController.php
Normal file
14
app/controllers/PaisController.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace app\controllers;
|
||||
|
||||
class PaisController{
|
||||
public function index(){
|
||||
$Log = new Controller();
|
||||
$Logins = $Log->getPais();
|
||||
echo json_encode($Logins);
|
||||
return json_encode($Logins);
|
||||
}
|
||||
public function store(){
|
||||
var_dump('store do login');
|
||||
}
|
||||
}
|
||||
@@ -64,4 +64,5 @@ try{
|
||||
//http://localhost:8000/login?NO_USERNAME=AMENEZES
|
||||
|
||||
//dados alunos
|
||||
//http://localhost:8000/aluno?NR_LOGRADOURO=715
|
||||
//http://localhost:8000/aluno?NR_LOGRADOURO=715
|
||||
//http://localhost:8000/aluno?NOME=JOAO%20MIGUEL%20DE
|
||||
@@ -22,7 +22,8 @@ $router= [
|
||||
"GET"=>[
|
||||
"/"=> fn()=> load("HomeController","index"),
|
||||
"/login" => fn()=> load("LoginController","index"),
|
||||
"/aluno" => fn()=> load("AlunoController","index")
|
||||
"/aluno" => fn()=> load("AlunoController","index"),
|
||||
"/pais" => fn()=> load("PaisController","index"),
|
||||
],
|
||||
"POST"=>[
|
||||
"/login" => fn()=> load("LoginController","store")
|
||||
|
||||
Reference in New Issue
Block a user