SHARE
TWEET

ModelUsuario.php

xlujiax Dec 3rd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //ModelUsuario.php
  2. <?php
  3. include_once '../util/Conexion.php';
  4. class ModelUsuario
  5. {
  6.     public function __construct()
  7.     {
  8.         $con = new Conexion();
  9.     }
  10.  
  11.     public function ModelInsertarUsuario($idtar,$nom,$ape,$niv,$usu,$cla,$tiptar,$numtar,$fecven,$ccv,$saldo){
  12.       try{
  13.            $obj = Conexion::singleton();
  14.            $query = $obj->prepare('INSERT INTO tbusuarios VALUES(?,?,?,?,?,?,?,?,?,?,?)');
  15.  
  16.            $query->bindParam(1, $idtar);
  17.            $query->bindParam(2, $nom);
  18.            $query->bindParam(3, $ape);
  19.            $query->bindParam(4, $niv);
  20.            $query->bindParam(5, $usu);
  21.            $query->bindParam(6, $cla);
  22.            $query->bindParam(7, $tiptar);
  23.            $query->bindParam(8, $numtar);
  24.            $query->bindParam(9, $fecven);
  25.            $query->bindParam(10,$ccv);
  26.            $query->bindParam(11,$saldo);
  27.  
  28.            $query->execute();//Ejecuta la consulta SQL
  29.         }catch(PDOException $e){
  30.               $e->getMessage();
  31.         }
  32.       }
  33.     public function ModelValidarUsuario($usu,$cla){
  34.       try{  
  35.            $obj = Conexion::singleton();
  36.            $query = $obj->prepare('SELECT * FROM tbusuarios WHERE Username=? AND Password=?');
  37.  
  38.            $query->bindParam(1, $usu);
  39.            $query->bindParam(2, $cla);
  40.  
  41.            $query->execute();//Ejecuta la consulta SQL
  42.            $vector = $query->fetchAll();
  43.            $query=null;
  44.            return $vector;
  45.         }catch(Exception $e){
  46.             throw $e;
  47.         }
  48.       }
  49.       public function ModelObtenerUsuario($user, $pass){
  50.           try{  
  51.                $obj = Conexion::singleton();
  52.                $query = $obj->prepare("SELECT * FROM tbusuarios WHERE Username=? and Password=?");
  53.  
  54.                $query->bindParam(1, $user);
  55.                $query->bindParam(2, $pass);
  56.  
  57.                $query->execute();//Ejecuta la consulta SQL
  58.                $vector = $query->fetchAll();
  59.                $query=null;
  60.                return $vector;
  61.             }catch(Exception $e){
  62.                 throw $e;
  63.             }
  64.       }
  65.       public function ModelModificarUsuario($id,$numt,$fec,$ccv,$rec){
  66.           try{  
  67.                $obj = Conexion::singleton();
  68.                $query = $obj->prepare('UPDATE tbusuarios SET Numero_Tarjeta=?, Fecha_Vencimiento=?,CCV=?, Saldo=? WHERE idtbusuarios=?');
  69.  
  70.                $query->bindParam(5, $id);
  71.                $query->bindParam(1, $numt);
  72.                $query->bindParam(2, $fec);
  73.                $query->bindParam(3, $ccv);
  74.                $query->bindParam(4, $rec);
  75.  
  76.                $query->execute();//Ejecuta la consulta SQL
  77.             }catch(PDOException $e){
  78.                   $e->getMessage();
  79.             }
  80.           }
  81.  
  82. }
  83. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top