2
I have a system where I need to list some employees. This listing will depend on the supervisor’s department code.
Ex: If the supervisor is from department 206, he can access all data from the departments' servers: (205,206,207,209);
Therefore, I am trying to query using Wherein and passing an array as parameter. However, I am not succeeding. I don’t know how to fix this situation.
So I’ll explain below how this part of the system works so you can help me if possible.
The function lotacaoSaude serves to return an array of departments that the supervisor can access.
$dep = Session::get('dep');
$deps = lotacaoSaude($dep);
Below is the way I mount my query:
$servidores = DB::table('sch_sismapa.tb_servidor')
->join('sch_decom.tb_servidor', 'sch_sismapa.tb_servidor.nr_matricula', '=', 'sch_decom.tb_servidor.nr_matricula')
->select('sch_decom.tb_servidor.nm_servidor', 'sch_sismapa.tb_servidor.*')
->where('sch_sismapa.tb_servidor.cd_secretaria','10')
->whereIN('sch_sismapa.tb_servidor.cd_departamento',[$deps])
->where('sch_sismapa.tb_servidor.id_referencia', '8')
->orderBy('sch_decom.tb_servidor.nm_servidor', 'asc')
->orderby('sch_decom.tb_servidor.cd_departamento', 'asc')
->get();
The way I did it presents the following error:
SQLSTATE[HY093]: Invalid Parameter number: Parameter was not defined
Remember that the cd_department column in the database is of the type integer
Thanks Augusto.
– douglas pjuizfora