CodeIgniter Forums

Full Version: sql query to CI query
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Need help to need to translate this mysql query to CI query in comparing two tables

MYSQL query in which give me results in phpmyadmin
SELECT tb_payroll . *,tb_payroll2.*
FROM tb_payroll
LEFT JOIN tb_payroll2 ON tb_payroll.payroll_id = tb_payroll2.payroll_id
WHERE tb_payroll.net_pay != tb_payroll2.net_pay

here's my controller+model function
function discrepancy(){
  $this->db->select('tb_payroll.*, tb_payroll2.*');
  $this->db->join('tb_payroll2','tb_payroll.payroll_id = tb_payroll2.payroll_id','left');
  $this->db->where('tb_payroll.net_pay !=','tb_payroll2.net_pay');
  $mpdf=new mPDF('c','A4','','',15,15,15,15,16,13);

my views in which I used different type of queries to have some result

foreach($query->result() as $row)
echo $row->tb_payroll.payroll_id;
echo $row->tb_payroll.net_pay;
echo $row->tb_payroll2.payroll_id;
echo $row->tb_payroll2.net_pay;
echo $row->net_pay;
echo $row->payroll_id;


El Forum

So, you mean, your CI query not working, right? Are you getting some kind of error or so? If yes, please share the error, which will help us to get idea what is wrong more easily. Thanks.