Change status if date is equal to or greater than today

0

I have this code:

$activox_count_query = tep_db_query("select * 
  from " . TABLE_ORDERS . " o, " . TABLE_GANTS . " g 
  where o.orders_status = '32' 
    and g.orders_id = o.orders_id 
    and g.title = 'Activar Servicio' 
    and g.start >= now()");
$activox_count = tep_db_fetch_array($activox_count_query);

tep_db_query("update " . TABLE_ORDERS . " 
  set orders_status = '32',
    last_modified = now()
  where orders_id = '" . (int)$activox_count['orders_id'] . "' 
    and orders_status = '31'");

I need if the gants table date that contains the title = 'Activar Servicio' and the start equal to or greater than today's date, make an update to the orders table.

Go from state 31 to 32 if and only if the day is greater than or equal to today, in YYYY:MM:DD include HH:MM:SS

    
asked by Ivan Diaz Perez 23.11.2016 в 19:48
source

1 answer

2

You could update all orders with a single query .

Try the following:

tep_db_query("
  UPDATE ".TABLE_ORDERS."
  SET orders_status = '32',
    last_modified = NOW()
  WHERE orders_status = '31'
    AND orders_id IN (
      SELECT orders_id 
      FROM ".TABLE_GANTS." 
      WHERE start >= NOW()
        AND title = 'Activar Servicio'
    )
");
    
answered by 23.11.2016 / 20:50
source