I have this query in MySQL:
select p.id_empleado as id,(select 'empleado') as tipo, p.url_imagen, concat_ws(' ',p.nombre,p.paterno,p.materno) as nombre,
e.nombre as empresa,concat_ws(' ',u.nombre,u.apellidos) as solicitante, p.fecha_alta, p.estado
from empleados p inner join usuarios u on p.id_usuario = u.id_usuario
inner join empresas e on u.id_empresa = e.id_empresa
union
select p.id_alumno as id,(select 'estudiante') as tipo, p.url_imagen, concat_ws(' ',p.nombre,p.paterno,p.materno) as nombre,
e.nombre as empresa,concat_ws(' ',u.nombre,u.apellidos) as solicitante, p.fecha_alta, p.estado
from estudiantes p inner join usuarios u on p.id_alumno = u.id_usuario
inner join empresas e on u.id_empresa = e.id_empresa
and transform it to a query with codeigniter style, for example:
$this->db->select('title, content, date');
$query = $this->db->get('mytable');
is equal to:
SELECT title, content, date FROM mytable
What I can think of is doing it with $this->db->query()
, but in my case it would not work for me because I want to get the results in another function, for example:
funcion 1{
$this->db->from("ejemplo");
}
funcion 2{
$this->funcion1();
$query = $this->db->get();
return $query->result();
}
The truth is that I do not know where to start, if helping me in something would be very helpful.