繁体   English   中英

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

[英]How to solve the date range search using CodeIgniter

控制器代码

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_php.php):无法打开流:C:\\ xampp \\ htdocs \\ portalacw中没有此类文件或目录\\ system \\ core \\ Exceptions.php在第269行

警告:include():无法在C:\\中打开'C:\\ xampp \\ htdocs \\ portalacw \\ application \\ views \\ errors \\ html \\ error_php.php'(include_path ='C:\\ xampp \\ php \\ PEAR')第269行的xampp \\ htdocs \\ portalacw \\ system \\ core \\ Exceptions.php

致命错误:在第24行的C:\\ xampp \\ htdocs \\ portalacw \\ application \\ modules \\ traffic \\ controllers \\ traffic.php中,调用成员函数cari()为null

警告:include(C:\\ xampp \\ htdocs \\ portalacw \\ application \\ views \\ errors \\ html \\ error_php.php):无法打开流:C:\\ xampp \\ htdocs \\ portalacw \\ system \\ core \\中没有此类文件或目录第269行的Exceptions.php

警告:include():无法在C:\\中打开'C:\\ xampp \\ htdocs \\ portalacw \\ application \\ views \\ errors \\ html \\ error_php.php'(include_path ='C:\\ xampp \\ php \\ PEAR')第269行的xampp \\ htdocs \\ portalacw \\ system \\ core \\ Exceptions.php

警告:include(C:\\ xampp \\ htdocs \\ portalacw \\ application \\ views \\ errors \\ html \\ error_php.php):无法打开流:C:\\ xampp \\ htdocs \\ portalacw \\ system \\ core \\中没有此类文件或目录第269行的Exceptions.php

警告:include():无法在C:\\中打开'C:\\ xampp \\ htdocs \\ portalacw \\ application \\ views \\ errors \\ html \\ error_php.php'(include_path ='C:\\ xampp \\ php \\ PEAR')第269行的xampp \\ htdocs \\ portalacw \\ system \\ core \\ Exceptions.php'

请帮我

我认为您的问题是因为未正确加载模型。 因此,您的控制器将traffic_model设置为null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM