-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgestionarUsuarios.php
112 lines (96 loc) · 3.38 KB
/
gestionarUsuarios.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
function alta_usuario($conexion,$usuario) {
try {
$consulta = "CALL nuevo_atleta(:nombre, :ape, :eda, :gen, :tel, :dic, :esta, :correo, :contra, :activo)";
$stmt=$conexion->prepare($consulta);
$stmt->bindParam(':nombre',$usuario["nombre"]);
$stmt->bindParam(':ape',$usuario["apellidos"]);
$stmt->bindParam(':eda',$usuario["edad"]);
$stmt->bindParam(':gen',$usuario["genero"]);
$stmt->bindParam(':tel',$usuario["telefono"]);
$stmt->bindParam(':dic',$usuario["direccion"]);
$stmt->bindParam(':esta',$usuario["estadoFisico"]);
$stmt->bindParam(':correo',$usuario["email"]);
$stmt->bindParam(':contra',$usuario["pass"]);
$stmt->bindParam(':activo',$usuario["activo"]);
$stmt->execute();
return true;
} catch(PDOException $e) {
return false;
}
}
function editar_usuario($conexion,$usuario,$perfil) {
try {
$consulta = "CALL actualizar_atleta(:id,:nombre, :ape, :eda, :gen, :tel, :dic, :esta, :correo, :contra, :activo)";
$stmt=$conexion->prepare($consulta);
$stmt->bindParam(':id',$perfil["IDATLETA"]);
$stmt->bindParam(':nombre',$usuario["nombre"]);
$stmt->bindParam(':ape',$usuario["apellidos"]);
$stmt->bindParam(':eda',$usuario["edad"]);
$stmt->bindParam(':gen',$usuario["genero"]);
$stmt->bindParam(':tel',$usuario["telefono"]);
$stmt->bindParam(':dic',$usuario["direccion"]);
$stmt->bindParam(':esta',$usuario["estadoFisico"]);
$stmt->bindParam(':correo',$usuario["email"]);
$stmt->bindParam(':contra',$usuario["pass"]);
$stmt->bindParam(':activo',$usuario["activo"]);
$stmt->execute();
return true;
} catch(PDOException $e) {
return false;
}
}
function eliminar_usuario($conexion,$perfil) {
try {
$consulta = "CALL eliminar_atleta(:id)";
$stmt=$conexion->prepare($consulta);
$stmt->bindParam(':id',$perfil["IDATLETA"]);
$stmt->execute();
return true;
} catch(PDOException $e) {
return false;
}
}
function consultarUsuario($conexion,$email,$pass) {
$consulta = "SELECT COUNT(*) AS TOTAL FROM ATLETAS WHERE CORREO=:email AND CONTRASENNA=:pass";
$stmt = $conexion->prepare($consulta);
$stmt->bindParam(':email',$email);
$stmt->bindParam(':pass',$pass);
$stmt->execute();
return $stmt->fetchColumn();
}
function getPerfil($conexion,$email){
try {
$consulta = "SELECT * FROM ATLETAS WHERE CORREO=:email";
$stmt=$conexion->prepare($consulta);
$stmt->bindParam(':email',$email);
$stmt->execute();
$result = $stmt->fetch();
return $result;
} catch(PDOException $e) {
return null;
}
}
function getUltimosResultadosEnCompeticiones($conexion,$perfil){
try {
$consulta = "SELECT * FROM (SELECT * FROM RESULTADOS NATURAL JOIN COMPETICIONES WHERE IDATLETA=:id AND (MARCA IS NOT NULL AND POSICION IS NOT NULL) ORDER BY FECHA DESC) WHERE ROWNUM < 5";
$stmt = $conexion->prepare($consulta);
$stmt->bindParam(':id',$perfil["IDATLETA"]);
$stmt->execute();
return $stmt->fetchAll();
}catch(PDOException $e){
return null;
}
}
function getUltimosEsfuerzosEnFeedbacks($conexion,$perfil){
try {
$consulta = "SELECT * FROM FEEDBACKS NATURAL JOIN MICROCICLOS WHERE IDATLETA=:id and ROWNUM < 5 ORDER BY FECHAFIN DESC";
$stmt = $conexion->prepare($consulta);
$stmt->bindParam(':id',$perfil["IDATLETA"]);
$stmt->execute();
return $stmt->fetchAll();
}catch(PDOException $e){
return null;
}
}
?>