Мне нужно найти данные за определенный диапазон дат.Пожалуйста, помогите мне
Модель
public function Date($start_date, $end_date){
$query = $this->db->select($this->tables['table_search'])
->where($this->tables['table_search'].'.created_at >=', $start_date)
->where($this->tables['table_search'].'.created_at <=', $end_date)
->group_by($this->tables['table_search'].".created_at")
->get($this->tables['table_search']);
return $query->result_array();
}
КОНТРОЛЛЕР
public function Date()
{
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$return = $this->m_model->Date($start_date,$end_date);
echo json_encode($return);
}
Ajax J'S
$('.input-daterange').datepicker({
todayBtn: 'linked',
format: "yyyy-mm-dd",
autoclose: true
});
функция fetch_data (start_date = '', end_date ='') {var dataTable = $ ('# table'). DataTable ({"processing": true, "serverSide": true, "order": [], "ajax": {url: "search / Date",тип: "POST", данные: {start_date: start_date, end_date: end_date}, success: function (data) {$ ('# table'). html (data);}}});}
$('#search').click(function(){
var start_date = $('#start_date').val();
var end_date = $('#end_date').val();
if(start_date != '' && end_date != ''){
$('#table').DataTable().destroy();
fetch_data(start_date,end_date);
}else{
}