"Trying to get property of non-object" error when accessing properties from CodeIgniter's row() method
I am using CodeIgniter to make a query and get the first row that I got. However, PHP gives me a 'Trying to get property of non-object' error. I already tried this same codes on my other model and it worked. I wonder where I went wrong. I'm getting the error on all the previous_records.
$receivable_query = $this->db
->select('invoice_no, cust_name, trans_date, due_date, amount')
->from('receivable_trans')
->where('invoice_no', $invoiceNumber)
->get();
$receivables_row = $receivable_query->row();
$previous_invoice_no = $receivables_row->invoice_no;
$previous_cust_name = $receivables_row->cust_name;
$previous_trans_date = $receivables_row->trans_date;
$previous_due_date = $receivables_row->due_date;
$previous_amount = $receivables_row->amount;