Advertisement
JoanMarcos

Classe Usuario

Sep 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. <?php
  2.     include_once('Conexao.php');
  3.     include_once('Endereco.php');
  4.     include_once('Cartao_Credito.php');
  5.     include_once('../Helpers/Helpers.php');
  6.  
  7.     abstract class Usuario {
  8.         private $Nome;
  9.         private $Senha;
  10.         private $Email;
  11.         private $Telefone;
  12.         private $NumeroParticipante;
  13.         private $TipoUsuario;
  14.  
  15.         public function __construct()
  16.         {
  17.             $this->con = new Conexao();
  18.             $this->Endereco = new Endereco();
  19.             $this->Cartao_Credito = new Cartao_Credito();
  20.         }
  21.  
  22.         public function __set($nome, $valor)
  23.         {
  24.             $this->$nome = $valor;
  25.         }
  26.  
  27.         public function __get($nome)
  28.         {
  29.             return $this->$nome;
  30.         }
  31.  
  32.         public  function queryAddUsuario($dados)
  33.         {
  34.             try {
  35.                 $this->Nome = $dados['Nome'];
  36.                 $this->Senha = md5($dados['Senha']);
  37.                 $this->Email = $dados['Email'];
  38.                 $this->Telefone = $dados['Telefone'];
  39.                 $this->NumeroParticipante = $dados['NumeroParticipante'];
  40.                 $this->TipoUsuario = $dados['TipoUsuario'];
  41.                 $values = $this->con->Conectar()->prepare("INSERT INTO usuario ('nome','senha','email','telefone','numero_participante','tipo_usuario')
  42.                                                                      VALUES (:nome,:senha,:email,:telefone,:numero_participante,:tipo_usuario);");
  43.                 $values->bindParam(":nome",$this->Nome, PDO::PARAM_STR);
  44.                 $values->bindParam(":senha",$this->Senha, PDO::PARAM_STR);
  45.                 $values->bindParam(":email",$this->Email, PDO::PARAM_STR);
  46.                 $values->bindParam(":telefone",$this->Telefone, PDO::PARAM_STR);
  47.                 $values->bindParam(":numero_participante",$this->NumeroParticipante, PDO::PARAM_STR);
  48.                 $values->bindParam(":tipo_usuario",$this->TipoParticipante, PDO::PARAM_STR);
  49.                 if ($values->execute())
  50.                     return 'ok';
  51.                 else
  52.                     return 'erro';
  53.             } catch (PDOException $e) {
  54.                 return 'error '.$e->getMessage();
  55.             }
  56.         }
  57.  
  58.  
  59.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement