如何使用codeigniter解决日期范围搜索

wpx232ag  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(317)

控制器代码

public function getcari(){

    $tglawal=date('Y-m-d', strtotime($this->input->post('tgl1', TRUE)));
    $tglakhir=date('Y-m-d', strtotime($this->input->post('tgl2', TRUE)));
    $data['detail']=$this->traffic_model->cari($tglawal,$tglakhir); 
    $this->load->view('daftar_traffic', $data); //menampilkan data yang sudah dicari
}

型号代码

function cari($tglawal,$tglakhir){      

$this->db->select('DATE_FORMAT(tgl, %d %M %Y) AS tanggal,COUNT(IF(kategori.parent=35 , VALUE, NULL)) AS Software,  COUNT(IF(kategori.parent=33 , VALUE, NULL)) AS Indent,  COUNT(IF(kategori.parent=32 , VALUE, NULL)) AS Ready, COUNT((DATE_FORMAT(tgl, %d - %m - %Y))) AS Total'); //changed the code here from COUNT(clients.id) AS num_rows
$this->db->from('masalah ');
$this->db->where('DATE(masalah.tgl) >=', $tglawal);
$this->db->where('DATE(masalah.tgl) <=', $tglakhir);
$this->db->join('kategori, kategori.kategori=masalah.kategori', 'left');
$this->db->group_by('tanggal');
$query = $this->db->get();
return $query->result();
}

查看代码

<form action="<?php echo site_url('traffic/getcari');?>" method="post"><input type="date" name="tgl1" palceholder="Input date" requaried="true" /> <input type="date" name="tgl2" palceholder="Input date" requaried="true" /><button type="submit">Cari</button> <a href="<?php echo site_url('traffic'); ?>" style="text-decoration:none; color: black;">Reset</a>

错误。。。警告:include(c:\xampp\htdocs\portalacw\application\views\errors\html\error\u php.php):未能打开流:在第269行的c:\xampp\htdocs\portalacw\system\core\exceptions.php中没有这样的文件或目录
警告:include():在第269行的c:\xampp\htdocs\portalacw\system\core\exceptions.php中打开“c:\xampp\htdocs\portalacw\application\views\errors\html\error\u php.php”以包含(include\u path='c:\xampp\php\pear')失败
致命错误:在第24行的c:\xampp\htdocs\portalacw\application\modules\traffic\controllers\traffic.php中对null的成员函数cari()进行调用
警告:include(c:\xampp\htdocs\portalacw\application\views\errors\html\error\u php.php):未能打开流:在第269行的c:\xampp\htdocs\portalacw\system\core\exceptions.php中没有这样的文件或目录
警告:include():在第269行的c:\xampp\htdocs\portalacw\system\core\exceptions.php中打开“c:\xampp\htdocs\portalacw\application\views\errors\html\error\u php.php”以包含(include\u path='c:\xampp\php\pear')失败
警告:include(c:\xampp\htdocs\portalacw\application\views\errors\html\error\u php.php):未能打开流:在第269行的c:\xampp\htdocs\portalacw\system\core\exceptions.php中没有这样的文件或目录
警告:include():在第269行打开“c:\xampp\htdocs\portalacw\application\views\errors\html\error\php.php”以包含(include\path='c:\xampp\php\pear')时失败
请帮帮我

qyuhtwio

qyuhtwio1#

在我看来,您的问题是因为您没有正确加载模型。所以你的管制员拿走了 traffic_model 成为 null .

相关问题