codeigniter Select_Sum回报"阵"没有数值? [英] Codeigniter Select_Sum returns "array" not numerical value?

查看:700
本文介绍了codeigniter Select_Sum回报"阵"没有数值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加了所有行的结果。使用select_sum如下:

I needed to add up all the rows for a result. Using the select_sum as follows

下面是模型

    function Dues_Paid_Tot($date)
{
    $query = $this->db->select_sum('Dues_Paid', 'Dues_Paid_Tot');
    $query = $this->db->get('Membership');
    return $query->result();
}

下面是控制器

    function Fiscal2()
{
$date = $this->input->post('Select_Date');
    if($query = $this->report_model->fiscal_list($date))
    {
        $data['records'] = $query;
    }
$data['date'] = $this->input->post('Select_Date');
$data['Dues_Paid_Tot'] = $this->report_model->Dues_Paid_Tot($date);
$data['main_content'] = 'report_fiscal_view';
$this->load->view('includes/template', $data);
}

这是相关的code为视图

And this is the pertinent code for the view

<?php echo $Dues_Paid_Tot; ?>

问题是,而不是显示在我看来列Dues_Paid,我得到阵的所有条目的总和。

The problem is, instead of showing a summation of all the entries in the column Dues_Paid, I get "Array" in my view.

我在哪里去了?

谢谢!

推荐答案

这仍然是一个查询,所以你还是要处理结果,尝试改变你的模型这个...

It is still a query so you still have to process the result, try changing your model to this...

function Dues_Paid_Tot($date)
{
    $query = $this->db->select_sum('Dues_Paid', 'Dues_Paid_Tot');
    $query = $this->db->get('Membership');
    $result = $query->result();

    return $result[0]->Dues_Paid_Tot;
}

这篇关于codeigniter Select_Sum回报&QUOT;阵&QUOT;没有数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆