1
|
|
|
<?php |
2
|
|
|
class usuarioModelo extends Sistema\Nucleo\CFModelo |
3
|
|
|
{ |
4
|
|
|
|
5
|
|
|
function ValidarUsuario($email,$password){ // Consulta Mysql para buscar en la tabla Usuario aquellos usuarios que coincidan con el mail y password ingresados en pantalla de login |
6
|
|
|
$query = $this->db->where('Usuario',$email); // La consulta se efectúa mediante Active Record. Una manera alternativa, y en lenguaje más sencillo, de generar las consultas Sql. |
|
|
|
|
7
|
|
|
$query = $this->db->where('Password',$password); |
8
|
|
|
$query = $this->db->get('Usuarios'); |
9
|
|
|
return $query->row(); // Devolvemos al controlador la fila que coincide con la búsqueda. (FALSE en caso que no existir coincidencias) |
10
|
|
|
} |
11
|
|
|
|
12
|
|
View Code Duplication |
public function insertarUsuario($id_usuario, $nombre, $email, $clave){ |
|
|
|
|
13
|
|
|
|
14
|
|
|
$post=$this->_bd->consulta('INSERT INTO comentarios (id_usuario, nombre, email, clave) VALUES (:id_usuario, :nombre, :email, :clave)'); |
|
|
|
|
15
|
|
|
$post=$this->_bd->enlace(':id_usuario', $id_usuariio); |
|
|
|
|
16
|
|
|
$post=$this->_bd->enlace(':nombre',$nombre); |
|
|
|
|
17
|
|
|
$post=$this->_bd->enlace(':email', $email); |
|
|
|
|
18
|
|
|
$post=$this->_bd->enlace(':clave', $clave); |
|
|
|
|
19
|
|
|
$post=$this->_bd->ejecucion(); |
20
|
|
|
return $post=$this->_bd->resultset(); |
21
|
|
|
|
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function seleccionUsuario($email, $clave){ |
25
|
|
|
//echo DB_HOST; |
26
|
|
|
|
27
|
|
|
//$datosQuery="select usuario, email, nivel from usuarios where usuario = :usuario"; |
28
|
|
|
$gsent=$this->_bd->consulta('select nombre, email, nivel from usuarios where email = :email and clave = :clave'); |
|
|
|
|
29
|
|
|
$gsent=$this->_bd->enlace(':email', $email); |
|
|
|
|
30
|
|
|
$gsent=$this->_bd->enlace(':clave', $clave); |
|
|
|
|
31
|
|
|
//$gsent=$this->_bd->ejecucion(); |
32
|
|
|
$row = $gsent=$this->_bd->single(); |
33
|
|
|
return $row; |
34
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
public function insertarRegistro($nombre, $email, $nivel, $clave){ |
38
|
|
|
|
39
|
|
|
$post=$this->_bd->consulta('INSERT INTO usuarios (nombre, email, nivel, clave) VALUES (:nombre, :email, :nivel, :clave)'); |
|
|
|
|
40
|
|
|
|
41
|
|
|
$post=$this->_bd->enlace(':nombre',$nombre); |
|
|
|
|
42
|
|
|
$post=$this->_bd->enlace(':email', $email); |
|
|
|
|
43
|
|
|
$post=$this->_bd->enlace(':nivel', $nivel); |
|
|
|
|
44
|
|
|
$post=$this->_bd->enlace(':clave', $clave); |
|
|
|
|
45
|
|
|
$post=$this->_bd->ejecucion(); |
46
|
|
|
//return $post=$this->_bd->contarFilas(); |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: