public function getPaymentsByMonth()
{
    return
    $this->db->select('sum(payment_grand) as grand')
                     ->where('MONTH(payment_date)', date('m'))
                     ->count_all_results('payments');
}

问题
在我的主管理页面中,我想计算本月的利润。

最佳答案

public function getPaymentsByMonth()
  {
      $sql = "SELECT SUM(`payment_grand`) AS grand FROM payments WHERE MONTH(`payment_date`)=MONTH( CURRENT_DATE )";
    $query= $this->db->query($sql);
    return $query->row('grand');
}

08-05 04:55