atr_profile_save

Versions
6.1
atr_profile_save(&$profile)

Save a settings profile.

Parameters

$profile The profile object to save.

Return value

The value returned by drupal_write_record() for saving the profile.

Code

atr/atr.module, line 246

<?php
function atr_profile_save(&$profile) {
  if (isset($profile->pid)) {
    $update = 'pid';
    db_query("DELETE FROM {atr_profile_method} WHERE pid = %d", $profile->pid);
  }
  else {
    $update = array();
  }
  $return = drupal_write_record('atr_profile', $profile, $update);
  if (count($profile->methods)) {
    $values = array();
    $placeholders = array();
    foreach ($profile->methods as $method) {
      $values[] = $profile->pid;
      $values[] = $method;
      $placeholders[] = "(%d, '%s')";
    }
    db_query("INSERT INTO {atr_profile_method} VALUES " . implode(',', $placeholders), $values);
  }

  return $return;
}
?>