![]() |
Complex DB query using CI helpers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Complex DB query using CI helpers (/showthread.php?tid=3088) |
Complex DB query using CI helpers - El Forum - 09-09-2007 [eluser]Guillem[/eluser] I have a table (altas) in my db with some foreign keys to other fields of other tables (clientes, estados, usuarios): Quote:idI was trying to use the helpers of CI, since I'd like to make a query with some values that might be entered into a form. My code is that: Code: $this->db->select('u.usuario, c.id as cid, c.apellidos, c.nombre, c.dni, e.estado, a.id, a.fecha, a.comentario, a.linea'); Code: $this->db->where('u.id','a.id_usuario'); Code: $this->db->query("SELECT u.usuario, c.id as cid, c.apellidos, c.nombre, c.dni, e.estado, a.id, a.fecha, a.comentario, a.linea FROM altas a, usuarios u, estados e, clientes c WHERE a.id_usuario='".$_POST['usuario']."' AND a.id_operadora='".$_POST['operadora']."' AND a.fecha>='".$_POST['desde']."' AND a.fecha<='".$_POST['hasta']."' AND a.id_estado='".$_POST['estado']."' AND u.id=a.id_usuario AND c.id=a.id_cliente AND e.id=a.id_estado ORDER BY a.fecha DESC"); Can any body make me see the light, please? Thank you all folks ![]() |