You are here

function filefield_paths_update_7104 in File (Field) Paths 7

Add active updating flag to {filefield_paths}

File

./filefield_paths.install, line 93
Install, update and uninstall functions for the File (Field) Paths module.

Code

function filefield_paths_update_7104() {
  db_add_field('filefield_paths', 'active_updating', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => '0',
  ));

  // migrate variable to filefield_paths table
  $result = db_query("SELECT name, value FROM {variable} WHERE name LIKE 'ffp_%%_field_%%'");
  foreach ($result as $row) {
    if (preg_match('/ffp_(.+)_field_(.+)$/', $row->name, $match)) {
      $active_updating = unserialize($row->value);
      if ($active_updating) {
        db_update('filefield_paths')
          ->fields(array(
          'active_updating' => $active_updating,
        ))
          ->condition('type', $match[1])
          ->condition('field', $match[2])
          ->execute();
      }
      variable_del($row->name);
    }
  }
}