criada a função para editar e deletar os dados do banco maria
This commit is contained in:
@@ -48,13 +48,67 @@ class Controller extends DBA{
|
||||
//print_r($this->res);
|
||||
//return $this->res;
|
||||
}
|
||||
public function getPais(){
|
||||
$this->sql = "SELECT * FROM usuarios";
|
||||
public function getPais($CD_ALUNO){
|
||||
$this->sql = "SELECT * FROM usuarios WHERE CD_ALUNO = ?";
|
||||
$this->stmt = self::$instMARIA->prepare($this->sql);
|
||||
$this->stmt->bindValue(1,$CD_ALUNO);
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $this-> res;
|
||||
}
|
||||
public function deletaPais($CPF){
|
||||
$this->sql = "DELETE FROM usuarios WHERE CPF = ?";
|
||||
$this->stmt = self::$instMARIA->prepare($this->sql);
|
||||
$this->stmt->bindValue(1,$CPF);
|
||||
$this->stmt->execute();
|
||||
if($this->stmt){
|
||||
echo 'deletado com sucesso';
|
||||
}else{
|
||||
echo 'erro';
|
||||
}
|
||||
}
|
||||
public function inserirPais(){
|
||||
$CD_ALUNO = $_POST['CD_ALUNO'];
|
||||
$CPF = $_POST['CPF'];
|
||||
$NOME = $_POST['NOME'];
|
||||
$SENHA = $_POST['SENHA'];
|
||||
$PARENTESCO = $_POST['PARENTESCO'];
|
||||
$DATA_CADASTRO = $_POST['DATA_CADASTRO'];
|
||||
$CONDICAO = $_POST['CONDICAO'];
|
||||
if($CONDICAO=='NOVO'){
|
||||
$this->sql = "INSERT INTO usuarios (CD_ALUNO, CPF, NOME, SENHA, PARENTESCO, DATA_CADASTRO, CONDICAO) VALUES (:CD_ALUNO, :CPF, :NOME, :SENHA, :PARENTESCO, :DATA_CADASTRO, :CONDICAO)";
|
||||
$this->stmt = self::$instMARIA->prepare($this->sql);
|
||||
$this->stmt->bindValue(':CD_ALUNO', $CD_ALUNO);
|
||||
$this->stmt->bindValue(':CPF', $CPF);
|
||||
$this->stmt->bindValue(':NOME', $NOME);
|
||||
$this->stmt->bindValue(':SENHA', $SENHA);
|
||||
$this->stmt->bindValue(':PARENTESCO', $PARENTESCO);
|
||||
$this->stmt->bindValue(':DATA_CADASTRO', $DATA_CADASTRO);
|
||||
$this->stmt->bindValue(':CONDICAO', $CONDICAO);
|
||||
$this->stmt->execute();
|
||||
$this->res = $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $this-> res;
|
||||
}
|
||||
if($this->stmt){
|
||||
echo 'cadastrado com sucesso';
|
||||
}else{
|
||||
echo 'erro';
|
||||
}
|
||||
}else{
|
||||
$this->sql = "UPDATE usuarios SET CD_ALUNO = :CD_ALUNO, NOME = :NOME, SENHA = :SENHA, PARENTESCO = :PARENTESCO, DATA_CADASTRO = :DATA_CADASTRO, CONDICAO = :CONDICAO WHERE CPF = :CPF";
|
||||
$this->stmt = self::$instMARIA->prepare($this->sql);
|
||||
$this->stmt->bindValue(':CD_ALUNO', $CD_ALUNO);
|
||||
$this->stmt->bindValue(':CPF', $CPF);
|
||||
$this->stmt->bindValue(':NOME', $NOME);
|
||||
$this->stmt->bindValue(':SENHA', $SENHA);
|
||||
$this->stmt->bindValue(':PARENTESCO', $PARENTESCO);
|
||||
$this->stmt->bindValue(':DATA_CADASTRO', $DATA_CADASTRO);
|
||||
$this->stmt->bindValue(':CONDICAO', $CONDICAO);
|
||||
$this->stmt->execute();
|
||||
if($this->stmt){
|
||||
echo 'editado com sucesso';
|
||||
}else{
|
||||
echo 'erro';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DBA{
|
||||
|
||||
Reference in New Issue
Block a user