Esta consulta me funciona bien en mysql pero quiero pasarlo a la forma CodeIgniter , models, me pueden ayudar con esto:
SELECT registro.*,CONCAT(usuarios.apellidos,', ',usuarios.nombres) as appnom FROM (SELECT *, bingo+chancho+pollada as total FROM (SELECT idusuario, sum(pagado) as bingo, sum('') as chancho, sum('') as pollada, 1 as tarjeta FROM tbingo b WHERE pagado=1 GROUP BY idusuario
union all
SELECT idusuario, sum('') as bingo, sum(pagado) as chancho, sum('') as pollada, 2 as tarjeta FROM tchancho c WHERE pagado=1 GROUP BY idusuario
union all
SELECT idusuario, sum('') as bingo, sum('') as chancho, sum(pagado) as pollada, 3 as tarjeta FROM tpollada p WHERE pagado=1 GROUP BY idusuario) as tabla
GROUP BY idusuario) as registro join usuarios ON registro.idusuario=usuarios.id