from('Orders') ->where('OrderStatus = ?', 'Pending') ->fetchArray(); foreach ($orders as $o) { if ($date < $o['DueDateTime']) { continue; } $q = Doctrine_Query::create() ->from('Orders') ->where('ProviderOrderId = ?', $o['ProviderOrderId']) ->fetchOne(); $q->DataSet = serialize(getDataSet($q->CompanyId, $q->DataSetType)); $q->OrderStatus = 'Completed'; $q->DateTimeCompleted = $date; $q->save(); print 'order '.$q->ProviderOrderId." updated\n"; } ?>