I have this function in my model the purpose of it is to get the stats of the past 30 days starting from the actual day, it was working fine before i reach 30th day then I found out it is counting from the oldest date, so I flipped the order_by from "ase" to "desc" but it seems still going back and counting before the oldest day and not giving me that data I want, so I'm wondering if there any way using codeigniter and give a starting point for the "limit" which should be the actual date.
function graph_data($id_person)
{
$this->db->limit(30); // get data for the last 30 days including the curent day
$this->db->where('personid',$id_person);
$this->db->order_by('date', 'ase');
$query = $this->db->get('stats');
foreach($query-> result_array() as $row)
{
$data[] = $row;
}
return $data;
}