You are here

function rooms_availability_update_7003 in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Remove orphaned rows from rooms_availability table.

File

modules/rooms_availability/rooms_availability.install, line 294
Install for Rooms Availability module - sets up the main Rooms Availability table

Code

function rooms_availability_update_7003() {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'rooms_unit')
    ->addMetaData('account', user_load(1));
  $result = $query
    ->execute();
  $delete = db_delete('rooms_availability');
  if (isset($result['rooms_unit']) && !empty($result['rooms_unit'])) {
    $ids = array_keys($result['rooms_unit']);
    $delete
      ->condition('unit_id', $ids, 'NOT IN');
  }
  $delete
    ->execute();
  return t('Removed orphaned rows from rooms_availability table');
}