You are here

function support_pm_update_6002 in Support Ticketing System 6

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

File

support_pm/support_pm.install, line 220

Code

function support_pm_update_6002() {
  $ret = array();
  db_add_field($ret, 'support_project', 'path', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'Project path.',
  ));
  $result = db_query('SELECT projid, project FROM {support_project}');
  while ($project = db_fetch_object($result)) {
    $path = strtolower(preg_replace('/[^0-9a-zA-Z]/', '', $project->project));
    $ret[] = update_sql("UPDATE {support_project} SET path = '{$path}' WHERE projid = {$project->projid}");
  }

  // 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($ret, 'support_project', 'path', array(
    'path',
  ));
  return $ret;
}