Doubt with codeigneter

0

I have two tables 'clients' and 'famClientes' connected by 'clients_idclientes'

When a client is added, this client can initiate a session where his data appear (until then I have no problem since he creates the session and shows data) the problem that I have is that I have to show all the information of famClientes for example: user1 (with id '3') has 2 people in famClientes.

Controller:

public function logueado() {
       if($this->session->userdata('logueado')){
         $data = array();
         $data['familiares'] = $this->usuario_model->familiares();
         $data['usuario'] = $this->session->userdata('usuario');
         $this->load->view('admin/inicio', $data);
         $this->usuario_model->familiares();
      }else{
         redirect('login');
      }
   }

Model

    function cliente($idclientes) {
      $consulta = $this->db->query('SELECT * FROM clientes WHERE idclientes='.$id);

      return $consulta->row();
   }



Public function familiares() {
      $consulta = $this->db->query('SELECT * FROM famClientes where clientes_idclientes=14');
      return $consulta->row();
   }

The client_customer = 14 I put it that way to do the test, but it only shows me 1, I need you to show me all of that id

    
asked by xkirit0x 17.01.2017 в 17:33
source

1 answer

0

Greetings and I hope you can use this ...

model

// row = lo usas por que es 1 o nada
function cliente($idclientes) {
      $consulta = $this->db->query('SELECT * FROM clientes WHERE idclientes='.$idclientes);
      return $consulta->row();
}

// result = respuesta puede ser 1 o mas
Public function familiares($idclientes){
      $consulta = $this->db->query('SELECT * FROM famClientes where clientes_idclientes'.$idclientes);
      return $consulta->result();
}
    
answered by 18.07.2018 в 13:16