Getting data posted in between two dates

后端 未结 10 1741
无人及你
无人及你 2020-12-08 00:15

How can I retrieve data from the database by querying records between two dates using CodeIgniter\'s activerecord?

10条回答
  •  难免孤独
    2020-12-08 01:13

    May this helpful to you.... With Join of Three Tables

    public function get_details_beetween_dates()
        {
            $from = $this->input->post('fromdate');
            $to = $this->input->post('todate');
    
            $this->db->select('users.first_name, users.last_name, users.email, groups.name as designation, dailyinfo.amount as Total_Fine, dailyinfo.date as Date_of_Fine, dailyinfo.desc as Description')
                        ->from('users')
                        ->where('dailyinfo.date >= ',$from)
                        ->where('dailyinfo.date <= ',$to)
                        ->join('users_groups','users.id = users_groups.user_id')
                        ->join('dailyinfo','users.id = dailyinfo.userid')
                        ->join('groups','groups.id = users_groups.group_id');
    
            /*
            $this->db->select('date, amount, desc')
                     ->from('dailyinfo')
                     ->where('dailyinfo.date >= ',$from)
                     ->where('dailyinfo.date <= ',$to);
            */
    
            $q = $this->db->get();
    
            $array['userDetails'] = $q->result();
            return $array;
        }
    

提交回复
热议问题