Код: Выделить всё
$where_payment = $this->get_where_report_period(db_prefix() . 'invoicepaymentrecords.date');
$this->db->select_sum('amount');
if($where_payment != ''){
$this->db->where($where_payment);
}
$this->db->where('((select count(*) from ' . db_prefix() . 'acc_account_history where ' . db_prefix() . 'acc_account_history.rel_id = ' . db_prefix() . 'invoicepaymentrecords.id and ' . db_prefix() . 'acc_account_history.rel_type = "payment") = 0) and currency = '.$data_currency);
$this->db->join(db_prefix() . 'invoices', db_prefix() . 'invoices.id=' . db_prefix() . 'invoicepaymentrecords.invoiceid', 'left');
$payment = $this->db->get(db_prefix().'invoicepaymentrecords')->row();
Код: Выделить всё
$this->db->select_sum('total');
if($where != ''){
$this->db->where($where);
}
$this->db->where('((select count(*) from ' . db_prefix() . 'acc_account_history where ' . db_prefix() . 'acc_account_history.rel_id = ' . db_prefix() . 'invoices.id and ' . db_prefix() . 'acc_account_history.rel_type = "invoice") = 0) and currency = '.$data_currency);
$invoice = $this->db->get(db_prefix().'invoices')->row();

Подробнее здесь: https://stackoverflow.com/questions/786 ... large-numb