How to pass an array in a WHERE condition

Asked

Viewed 116 times

4

$this->db->set('al_reg', $matricula);
$this->db->set('dataagendamento', $dataagendamento);
$this->db->where('cod_lab', $laboratorio);
$this->db->where('cod_horario', $horario_prova);
$this->db->where('cod_data', $data_prova);
$this->db->where('cod_assento', $assento[]);
$this->db->where('al_reg', NULL);
$this->db->update('P_chekin_Geral');

In this model is almost everything being updated straight, only the cod_assento which is a vector of 1 to 22 for each laboratory.

Does anyone have any idea if there is a possibility to add a 22 vector where each record will record in sequence and then reboot? example:

lab acessento 
  1        1
  1        2
  1        3..
  1        22
  2        1
  2        2
  2        3..
  2        22
  3        1..
  3        22

1 answer

4


Exchange the where() by conventional where_in(), the first only compares a value with a certain column ex: WHERE nome = 'fulano'. The second compares a series of values with a column to sql generated would be more or less like this: WHERE nome IN ('fulano', 'fuleiro', 'joão')

Change:

$this->db->where('cod_assento', $assento[]);

For:

$this->db->where_in('cod_assento', $assento);
  • type, I already have all the seats registered in the bank I just need, update the $registration and the $scheduling if I put this where_in() resolves?

  • 1

    @web_charles when you use the where() normal your consultation looks like this : where coluna = valor with the where_in() stays: where coluna in(elemento1, elemento2 ... N)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.