CodeIgniter Forums
Return No of rows as Days in between - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Return No of rows as Days in between (/showthread.php?tid=81701)



Return No of rows as Days in between - lazyme114 - 04-13-2022

Hi all, I am doing something like this:- 
PHP Code:
    $query $this->db->where(array(
        'user_id' => $user_id,
        'date(start) >=' => $start_date,
        'date(end) <=' => $end_date
    
))->order_by('start''asc')->get($table)->result(); 

It is working fine. But I want it to return a single row for each days between start and end even if data doesn't exists.


RE: Return No of rows as Days in between - badger - 04-13-2022

group by date


RE: Return No of rows as Days in between - lazyme114 - 04-13-2022

(04-13-2022, 02:47 AM)badger Wrote: group by date
it would have worked. but I want data even if that days data doesn't exists. maybe an empty row or something like that.


RE: Return No of rows as Days in between - lazyme114 - 04-13-2022

Found New Way 
PHP Code:
      SELECT FROM bf_attendance where checkin >  2022-03-15 interval 1 month 

but still if no data no row..


RE: Return No of rows as Days in between - JustJohnQ - 04-13-2022

You can't pull data from MySQL which doesn't exist. If it's that important I would loop through the returned data and add a blank record/object/array when I find an empty date,


RE: Return No of rows as Days in between - lazyme114 - 04-13-2022

(04-13-2022, 01:51 PM)JustJohnQ Wrote: You can't pull data from MySQL which doesn't exist. If it's that important I would loop through the returned data and add a blank record/object/array when I find an empty date,

Currently, I am doing exactly that but, Its for a monthly report and I have to loop through employee first then the sql query comes. If I have 30 employee I have to run 900 query in average. So you see my problem right. I want something that will take less time and load faster.