仅当今天的日期大于数据库中的日期时才更新记录

I have records in the database looking like the following:

RES_ID | RES_CHECK_IN  | RES_CHECK_OUT
----------------------------------------
  1685 |   08/10/2015  | 12/10/2015
  1684 |   24/10/2015  | 28/10/2015
  1683 |   20/09/2015  | 22/09/2015
   105 |   03/04/2015  | 06/04/2015

I want to update only RES ID 105 because today's date (01/10/2015) is bigger then the CHECK OUT DATE of RES ID 105. I tried doing this:

Model:

function update_columns_lock($res_id)
{
   $data = array('IS_COLUMNS_LOCKED_AFTER_CHECKOUT' => 1);
   $this->db->where('RES_ID' ,$res_id);
   $this->db->update('reservations',$data);
}

And the execution:

$today = time();
if ($today > strtotime($row->RES_CHECK_OUT)) {

    $ci = &get_instance();
    $ci->Reservations_model->update_columns_unlock($row->RES_ID);
}

Which seems to just randomly update the reservations.. no with the logic i wanted. what do i miss here?

I believe it's a issue with your date format. The below code should help you out as it creates a format that strtotime understands.

$tmp_convert_time = date_create_from_format("d/m/Y",$row->RES_CHECK_OUT);

if ($today > strtotime(date_format($tmp_convert_time, 'd/m/Y'))) {
   <CODE HERE>
}

Try the following code :

if (strtotime(date()) > strtotime($row->RES_CHECK_OUT)) {
    $ci = &get_instance();
    $ci->Reservations_model->update_columns_unlock($row->RES_ID);
}

My solution:

function lock_columns_after_checkout()
{
    $custom_sql_command = 'UPDATE reservations SET IS_COLUMNS_LOCKED_AFTER_CHECKOUT = 1 WHERE DATE(RES_CHECK_OUT) < DATE(NOW())';
    $this->db->query($custom_sql_command);
}