Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace sitemodulo1;
- include_once 'init.php';
- class Pessoa
- {
- private $cpf;
- private $rg;
- private $nome;
- private $data_nascimento;
- private $endereco;
- private $bairro;
- private $cidade;
- private $estado;
- private $pais;
- private $cep;
- function setPessoa( $cpf, $rg, $nome, $data_nascimento, $endereco,
- $bairro,$cidade, $estado, $pais, $cep){
- $this->cpf= $cpf;
- $this->rg = $rg;
- $this->nome = $nome;
- $this->data_nascimento = $data_nascimento;
- $this->endereco = $endereco;
- $this->bairro = $bairro;
- $this->cidade = $cidade;
- $this->estado = $estado;
- $this->pais = $pais;
- $this->cep = $cep;
- }
- function getPessoa($table){
- $sql = "SELECT cpf, rg, nome, data_nascimento, endereco,
- bairro,cidade, estado, pais, cep FROM $table";
- $q='';
- $q->exec(sql);
- foreach ($q as $row) {
- $data[]=$q;
- }
- return $data;
- // $connexao->closeConnection();
- }
- function postPessoa($table){
- $dados = array($this->cpf, $this->rg, $this->nome, $this->data_nascimento, $this->endereco, $this->bairro, $this->cidade, $this->estado, $this->pais, $this->cep);
- $conn->prepare("INSERT INTO $table (cpf, rg, nome, data_nascimento, endereco, bairro,cidade, estado, pais, cep)
- VALUES (:cpf, :rg, :nome, :data_nascimento, :endereco, :bairro,:cidade, :estado, :pais, :cep)")->execute($dados);
- unset($conn);
- }
- function updatePessoa($table){
- }
- function deletePessoa($table){
- }
- }
- <?php
- namespace site;
- use sitemodulo1Pessoa;
- include_once 'site/modulo1/Pessoa.php';
- class Aluno
- {
- private $matricula;
- private $Pessoa;
- function __construct() {
- $this->Pessoa = new Pessoa();
- }
- public function setAluno( $cpf, $rg, $nome, $data_nascimento,
- $endereco, $bairro,$cidade, $estado, $pais, $cep){
- $this->Pessoa->setPessoa($cpf, $rg, $nome, $data_nascimento,
- $endereco, $bairro, $cidade, $estado, $pais, $cep);
- }
- public function postAluno(){
- $this->Pessoa->postPessoa();
- }
- public function listaAlunos(){
- $this->Pessoa->getPessoa('alunos');
- }
- /**
- * @return mixed
- */
- public function getMatricula()
- {
- return $this->matricula;
- }
- /**
- * @return sitemodulo1Pessoa
- */
- public function getPessoa()
- {
- return $this->Pessoa;
- }
- /**
- * @param mixed $matricula
- */
- public function setMatricula($matricula)
- {
- $this->matricula = $matricula;
- }
- /**
- * @param sitemodulo1Pessoa $Pessoa
- */
- public function setPessoa($Pessoa)
- {
- $this->Pessoa = $Pessoa;
- }
- }
- ?>
- <div class="panel panel-warning">
- <div class="panel-heading">
- <h3>Listando Alunos</h3>
- </div>
- <div class="panel-body">
- <a href="index.php?pagina=site_modulo1_Aluno" class="btn btn-
- primary"> <span class="glyphicon glyphicon-plus"> </span> Novo
- Aluno</a>
- <br><br>
- <table class="listagem table table-bordered table-striped
- table-responsive">
- <thead>
- <tr>
- <th>matricula</th>
- <th>cpf</th>
- <th>rg</th>
- <th>nome</th>
- <th>data nascimento</th>
- <th>endereco<th>
- <th>bairro</th>
- <th>cidade</th>
- <th>estado</th>
- <th>pais</th>
- <th>cep</th>
- <th width="90px">Editar</th>
- <th width="90px">Excluir</th>
- </tr>
- </thead>
- <tbody>
- <?php $Aluno = new Pessoa();
- $Aluno->getPessoa('alunos');
- Foreach ($results as $Aluno) { ?>
- <tr>
- <td><b><?php echo $Aluno->getMatricula();?></b></td>
- <td><?php echo $Aluno->getCpf();?></td>
- <td><?php echo $Aluno->getRG() ?></td>
- <td><a href="index.php?pagina=estados_editar&id=<?php echo $Aluno->getMatricula;?>">Editar</a></td>
- <td><a href="index.php?pagina=estados_excluir&id=<?php echo $Aluno->getMatricula;?>">Excluir</a></td>
- </tr>
- <?php } ?>
- </tbody>
- <tfoot>
- <tr>
- <th colspan="5" class="text-center"><?php echo date('d/m/Y h:i:s'); ?></th>
- </tr>
- </tfoot>
- </table>
- </div>
- <?php
- namespace site;
- use sitemodulo1Pessoa;
- include_once 'site/modulo1/Pessoa.php';
- /**
- * @author developer Fabiano
- *
- * relação de composição com classe Pessoa;
- */
- class Aluno
- {
- private $matricula;
- private $Pessoa;
- function __construct() {
- $this->Pessoa = new Pessoa();
- }
- public function setAluno( $cpf, $rg, $nome, $data_nascimento, $endereco, $bairro,$cidade, $estado, $pais, $cep){
- $this->Pessoa->setPessoa($cpf, $rg, $nome, $data_nascimento, $endereco, $bairro, $cidade, $estado, $pais, $cep);
- }
- public function postAluno(){
- $this->Pessoa->postPessoa();
- }
- public function listaAlunos(){
- $this->Pessoa->getPessoa('alunos');
- }
- GETTERS AND SETERS
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement