Kamal Varma Kambe Wed Mar 21 09:20:18 -0400 2012

Subject: get the records that are updated on the current day

I have a DB table with last_update_time (type - datetime) as one of the columns. I update the value whenever a particular insertion occurs.

My requirement is I need to get the rows that are updated on the current day. I need to get this by using ActiveRecord. How do I do it? Please guide.

Thanks,
Kamal


Mr. Carl Sat Apr 14 17:44:56 -0400 2012
1 $today = new ActiveRecord\DateTime('now');    // extends class off php DateTime
2 $start_today = $today->format('Y-m-d')." 00:00:00";
3 $end_today = $today->format('Y-m-d')." 23:59:59"; 
4 Model::all(array('conditions' => array('last_update_time >= ? AND price < ?', $start_today, $end_today )));

I haven't tested the code and I don't know which database your using if this could affect the condition. (Being AR it shouldn't) If you don't need to edit the model(s) you may want to add 'readonly' => true.

(1-1/1)