I am using Codeigniter 4 ORM and I have a doubt.
I have to implement this query using the CI4 ORM model:
SELECT
*
FROM
usuarios_sucursales
WHERE
sucursales_idsucursal = '.$sucursal.'
AND usuarios_idusuario in (
SELECT
idusuario
FROM
usuarios
WHERE
tipo_usuario = '.$tipo_usuario.'
)
But I don't know how I can implement this with the CI4 ORM.
I have this in my code so far:
$intance_app = new AplicacionesSucursalesModel();
$usuarios_instance = new UsuariosModel();
$sql_user = $usuarios_instance
->select("idusuario")
->where("tipo_usuario", $tipo_usuario)
->findAll();
$usuarios= $intance_app
->where("sucursales_idsucursal",$sucursal)
->whereIn('sucursales_idsucursal', $sql_user)
->findAll();
But I get "Array to string conversion"
error when I try to get the results of the query.