从存在表计算

I want to count data from exist table which the date is today. And everyday it counts automaticaly.

I have pembayaran table that include 'tanggal' column as date and 'total' column as number that i will count. I've tried this code. But it always give me '0'. Did i forget something?

Controller

public function index(){
               $today = date('Y-m-d');
               $where = array('tanggal' => $today);
               $getpem = $this->aruskas_m->selectX('pembayaran',$where)->result();
               $jumlah =0;
               foreach ($getpem as $row) {
                   $jumlah += $row->total;
               }
               $data['kasmasuk'] = $jumlah;        

               $this->load->view('laporan/aruskas_v', $data);
    }

Change

$where = array('tanggal' => $today);

to

$where = array('date(tanggal)='. $today);

Please make sure your date field's format is exactly like this Y-m-d format. Otherwise you have to change the date format of $today perfectly matching with tanggal field in your condition $where = array('tanggal' => $today);