function searchAdmin(Administrador $a) { require_once '../conexion.php'; require_once '../model.business/Administrador.php'; require_once '../model.business/Persona.php'; try { $conexion = new conexion(); $administrador = new Administrador(); $sql = "SELECT a.nombre, a.apellido FROM administrador a " . "INNER JOIN login l ON a.username = l.username " . "WHERE l.username = '******' AND l.contraseña = '" . $a->getPassword() . "';"; $conn = $conexion->conn(); $query = $conn->query($sql); $rows = $query->fetchAll(); foreach ($rows as $row) { $administrador->setUsername($a->getUsername()); $administrador->setPassword($a->getPassword()); $administrador->setRol(0); $administrador->setNombre($row["nombre"]); $administrador->setApellido($row["apellido"]); } return $administrador; } catch (Exception $ex) { $ex->getTraceAsString(); } }
function insertLoginAdmin(Administrador $a) { require_once '../conexion.php'; require_once '../model.business/Cliente.php'; try { $username = $a->getUsername(); $password = $a->getPassword(); $conexion = new conexion(); $conn = $conexion->conn(); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = $conn->prepare("INSERT INTO login VALUES(:username,:password, 1);"); $sql->bindParam(':username', $username); $sql->bindParam(':password', $password); return $sql->execute(); } catch (PDOException $exc) { return $exc->getCode(); } finally { } }