You are here

function support_pm_update_6002 in Support Ticketing System 7

Same name and namespace in other branches
  1. 6 support_pm/support_pm.install \support_pm_update_6002()

Add path to {support_project}.

File

support_pm/support_pm.install, line 203

Code

function support_pm_update_6002() {
  db_add_field('support_project', 'path', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Project path.',
  ));
  $result = db_query('SELECT projid, project FROM {support_project}');
  foreach ($result as $project) {
    $path = strtolower(preg_replace('/[^0-9a-zA-Z]/', '', $project->project));
    db_update('support_project')
      ->fields(array(
      'path' => $path,
    ))
      ->condition('projid', $project->projid)
      ->execute();
  }

  // Add index after conversion, as otherwise it will fail as all paths will be
  // the same, ''.  If there'd been an actual release of this module already,
  // we'd add more error checking here to handle multiple projects of the same
  // name.
  db_add_index('support_project', 'path', array(
    'path',
  ));
}