Codeigniter 我无法在我的查看页面中获取$result['query']

Codeigniter 我无法在我的查看页面中获取$result['query'],codeigniter,Codeigniter,我的控制器Erp\U c: $result['query2']= $this->erp_m->selectattend1($user,$en,$year,$month); $this->load->('salview',$result); 在型号Erp_m中: function selectattend1($user,$en,$year,$month) { $query2=$this->db->query(" SELECT COUNT(*) FROM a

我的控制器Erp\U c:

$result['query2']= $this->erp_m->selectattend1($user,$en,$year,$month);
$this->load->('salview',$result);
在型号Erp_m中:

function selectattend1($user,$en,$year,$month)
{
  $query2=$this->db->query(" SELECT COUNT(*)
FROM attendance3
WHERE name = '$en'
AND attend = 'Absent'
AND MONTH = '$month'
AND year = '$year'
AND user = '$user' ");

return $query2->result(); 

}
在视图页面salview.php中:

 foreach($query2 as $row)

{
$al=$row->count(*);///here what i put ,that is my doubt
,because $result['query']= Array ( [0] => stdClass Object ( [COUNT(*)] => 1 ) )
}
如何在查看页面中获取计数值?

在控制器中

$result['query2']= $this->erp_m->selectattend1($user,$en,$year,$month);//get data
$result['count']= $this->erp_m->get_selectattend1_count($user,$en,$year,$month);//get count
模型中

function selectattend1($user,$en,$year,$month)
{
    $query2 = $this->db->query(" SELECT COUNT(*)
            FROM attendance3
            WHERE name = '$en'
            AND attend = 'Absent'
            AND MONTH = '$month'
            AND year = '$year'
            AND user = '$user' ");

    $result = $query2->result_array();
    return $result;
}

function get_selectattend1_count($user,$en,$year,$month)
{
    $query2 = $this->db->query(" SELECT COUNT(*)
            FROM attendance3
            WHERE name = '$en'
            AND attend = 'Absent'
            AND MONTH = '$month'
            AND year = '$year'
            AND user = '$user' ");

    $result = $query2->result_array();
    $count = count($result);
    return $count;
}
鉴于

您可以访问veriables$query2和$count

内部控制器

$result['query2']= $this->erp_m->selectattend1($user,$en,$year,$month);//get data
$result['count']= $this->erp_m->get_selectattend1_count($user,$en,$year,$month);//get count
模型中

function selectattend1($user,$en,$year,$month)
{
    $query2 = $this->db->query(" SELECT COUNT(*)
            FROM attendance3
            WHERE name = '$en'
            AND attend = 'Absent'
            AND MONTH = '$month'
            AND year = '$year'
            AND user = '$user' ");

    $result = $query2->result_array();
    return $result;
}

function get_selectattend1_count($user,$en,$year,$month)
{
    $query2 = $this->db->query(" SELECT COUNT(*)
            FROM attendance3
            WHERE name = '$en'
            AND attend = 'Absent'
            AND MONTH = '$month'
            AND year = '$year'
            AND user = '$user' ");

    $result = $query2->result_array();
    $count = count($result);
    return $count;
}
鉴于

您可以访问veriables$query2和$count


为什么在视图中计数??为什么在视图中计数??我如何在视图页面中访问$count,我在视图页面中执行了此操作您可以使用foreach{}循环或仅使用echo print_r$count;如果还有一个计数,例如:$result['count1']=$this->erp\m->get\u selectattend2\u count$user,$en,$year,$month;例如:在模型erp_m$query3=$this->db->query中,从attendance3中选择COUNT*,其中name='en'和Attendant='present',MONTH='MONTH'和year='year',user='$user'$结果=$query3->result\u数组//打印结果;死亡$count1=count$结果;返回$count1,但是我无法在查看页面中获取$count1您想对计数做什么?我想不休假该人没有休假,也没有休假显示我在查看页面中访问$count,我在查看页面中执行了此操作您可以使用foreach{}循环或仅使用echo print_r$count;如果还有一个计数,例如:$result['count1']=$this->erp\m->get\u selectattend2\u count$user,$en,$year,$month;例如:在模型erp_m$query3=$this->db->query中,从attendance3中选择COUNT*,其中name='en'和Attendant='present',MONTH='MONTH'和year='year',user='$user'$结果=$query3->result\u数组//打印结果;死亡$count1=count$结果;返回$count1,但是我不能得到$count1在查看页面上你到底想用count做什么?我不想休假这个人没有带过礼物也没有带过假期