You are here

function course_update_6121 in Course 7

Same name and namespace in other branches
  1. 6 course.install \course_update_6121()
  2. 7.2 course.install \course_update_6121()

Delete enrollments for users who don't exist anymore.

File

./course.install, line 535
course.install Install and update functions for Courses.

Code

function course_update_6121() {
  $ret = array();
  $sql = "DELETE ce.* FROM {course_enrolment} ce LEFT JOIN {users} u ON (ce.uid = u.uid) WHERE u.uid IS NULL";
  $ret[] = array();
  $ret[] = array(
    'success' => TRUE,
    'query' => db_affected_rows() . ' old enrollments deleted',
  );

  // hook_update_N() no longer returns a $ret array. Instead, return
  // nothing or a translated string indicating the update ran successfully.
  // See http://drupal.org/node/224333#update_sql.
  return t('TODO Add a descriptive string here to show in the UI.');
}