Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. <?php
  2. namespace sitemodulo1;
  3.  
  4.  
  5. include_once 'init.php';
  6.  
  7. class Pessoa
  8. {
  9. private $cpf;
  10. private $rg;
  11. private $nome;
  12. private $data_nascimento;
  13. private $endereco;
  14. private $bairro;
  15. private $cidade;
  16. private $estado;
  17. private $pais;
  18. private $cep;
  19.  
  20.  
  21.  
  22. function setPessoa( $cpf, $rg, $nome, $data_nascimento, $endereco,
  23. $bairro,$cidade, $estado, $pais, $cep){
  24.  
  25. $this->cpf= $cpf;
  26. $this->rg = $rg;
  27. $this->nome = $nome;
  28. $this->data_nascimento = $data_nascimento;
  29. $this->endereco = $endereco;
  30. $this->bairro = $bairro;
  31. $this->cidade = $cidade;
  32. $this->estado = $estado;
  33. $this->pais = $pais;
  34. $this->cep = $cep;
  35.  
  36. }
  37. function getPessoa($table){
  38.  
  39. $sql = "SELECT cpf, rg, nome, data_nascimento, endereco,
  40. bairro,cidade, estado, pais, cep FROM $table";
  41. $q='';
  42. $q->exec(sql);
  43.  
  44.  
  45. foreach ($q as $row) {
  46.  
  47. $data[]=$q;
  48. }
  49.  
  50. return $data;
  51. // $connexao->closeConnection();
  52. }
  53.  
  54. function postPessoa($table){
  55.  
  56. $dados = array($this->cpf, $this->rg, $this->nome, $this->data_nascimento, $this->endereco, $this->bairro, $this->cidade, $this->estado, $this->pais, $this->cep);
  57.  
  58. $conn->prepare("INSERT INTO $table (cpf, rg, nome, data_nascimento, endereco, bairro,cidade, estado, pais, cep)
  59. VALUES (:cpf, :rg, :nome, :data_nascimento, :endereco, :bairro,:cidade, :estado, :pais, :cep)")->execute($dados);
  60. unset($conn);
  61. }
  62.  
  63.  
  64. function updatePessoa($table){
  65.  
  66. }
  67.  
  68. function deletePessoa($table){
  69.  
  70. }
  71.  
  72. }
  73.  
  74. <?php
  75. namespace site;
  76.  
  77. use sitemodulo1Pessoa;
  78.  
  79.  
  80.  
  81. include_once 'site/modulo1/Pessoa.php';
  82.  
  83.  
  84.  
  85. class Aluno
  86. {
  87. private $matricula;
  88. private $Pessoa;
  89.  
  90. function __construct() {
  91.  
  92. $this->Pessoa = new Pessoa();
  93.  
  94. }
  95.  
  96. public function setAluno( $cpf, $rg, $nome, $data_nascimento,
  97. $endereco, $bairro,$cidade, $estado, $pais, $cep){
  98.  
  99. $this->Pessoa->setPessoa($cpf, $rg, $nome, $data_nascimento,
  100. $endereco, $bairro, $cidade, $estado, $pais, $cep);
  101. }
  102.  
  103.  
  104. public function postAluno(){
  105.  
  106. $this->Pessoa->postPessoa();
  107.  
  108. }
  109.  
  110. public function listaAlunos(){
  111.  
  112. $this->Pessoa->getPessoa('alunos');
  113.  
  114. }
  115. /**
  116. * @return mixed
  117. */
  118. public function getMatricula()
  119. {
  120. return $this->matricula;
  121. }
  122.  
  123. /**
  124. * @return sitemodulo1Pessoa
  125. */
  126. public function getPessoa()
  127. {
  128. return $this->Pessoa;
  129. }
  130.  
  131. /**
  132. * @param mixed $matricula
  133. */
  134. public function setMatricula($matricula)
  135. {
  136. $this->matricula = $matricula;
  137. }
  138.  
  139. /**
  140. * @param sitemodulo1Pessoa $Pessoa
  141. */
  142. public function setPessoa($Pessoa)
  143. {
  144. $this->Pessoa = $Pessoa;
  145. }
  146.  
  147.  
  148. }
  149. ?>
  150. <div class="panel panel-warning">
  151. <div class="panel-heading">
  152. <h3>Listando Alunos</h3>
  153. </div>
  154.  
  155. <div class="panel-body">
  156. <a href="index.php?pagina=site_modulo1_Aluno" class="btn btn-
  157. primary"> <span class="glyphicon glyphicon-plus"> </span> Novo
  158. Aluno</a>
  159. <br><br>
  160. <table class="listagem table table-bordered table-striped
  161. table-responsive">
  162. <thead>
  163. <tr>
  164. <th>matricula</th>
  165. <th>cpf</th>
  166. <th>rg</th>
  167. <th>nome</th>
  168. <th>data nascimento</th>
  169. <th>endereco<th>
  170. <th>bairro</th>
  171. <th>cidade</th>
  172. <th>estado</th>
  173. <th>pais</th>
  174. <th>cep</th>
  175. <th width="90px">Editar</th>
  176. <th width="90px">Excluir</th>
  177. </tr>
  178. </thead>
  179. <tbody>
  180. <?php $Aluno = new Pessoa();
  181. $Aluno->getPessoa('alunos');
  182. Foreach ($results as $Aluno) { ?>
  183.  
  184. <tr>
  185. <td><b><?php echo $Aluno->getMatricula();?></b></td>
  186. <td><?php echo $Aluno->getCpf();?></td>
  187. <td><?php echo $Aluno->getRG() ?></td>
  188. <td><a href="index.php?pagina=estados_editar&id=<?php echo $Aluno->getMatricula;?>">Editar</a></td>
  189. <td><a href="index.php?pagina=estados_excluir&id=<?php echo $Aluno->getMatricula;?>">Excluir</a></td>
  190. </tr>
  191. <?php } ?>
  192. </tbody>
  193. <tfoot>
  194. <tr>
  195. <th colspan="5" class="text-center"><?php echo date('d/m/Y h:i:s'); ?></th>
  196. </tr>
  197. </tfoot>
  198. </table>
  199. </div>
  200.  
  201. <?php
  202. namespace site;
  203.  
  204. use sitemodulo1Pessoa;
  205.  
  206. include_once 'site/modulo1/Pessoa.php';
  207.  
  208.  
  209. /**
  210. * @author developer Fabiano
  211. *
  212. * relação de composição com classe Pessoa;
  213. */
  214. class Aluno
  215. {
  216. private $matricula;
  217. private $Pessoa;
  218.  
  219. function __construct() {
  220.  
  221. $this->Pessoa = new Pessoa();
  222.  
  223. }
  224.  
  225. public function setAluno( $cpf, $rg, $nome, $data_nascimento, $endereco, $bairro,$cidade, $estado, $pais, $cep){
  226.  
  227. $this->Pessoa->setPessoa($cpf, $rg, $nome, $data_nascimento, $endereco, $bairro, $cidade, $estado, $pais, $cep);
  228. }
  229.  
  230.  
  231. public function postAluno(){
  232.  
  233. $this->Pessoa->postPessoa();
  234.  
  235. }
  236.  
  237. public function listaAlunos(){
  238.  
  239. $this->Pessoa->getPessoa('alunos');
  240.  
  241. }
  242.  
  243. GETTERS AND SETERS
  244.  
  245. }
  246. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement