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