$apiRequest['params'][$key_id], 'version' => $apiRequest['version']]; $existing = civicrm_api($apiRequest['entity'], 'get', $seek); if ($existing['is_error']) { return $existing; } if ($existing['count'] > 1) { return civicrm_api3_create_error("More than one " . $apiRequest['entity'] . " with id " . $apiRequest['params'][$key_id]); } if ($existing['count'] == 0) { return civicrm_api3_create_error("No " . $apiRequest['entity'] . " with id " . $apiRequest['params'][$key_id]); } $existing = array_pop($existing['values']); // Per Unit test testUpdateHouseholdWithAll we don't want to load these from the DB // if they are not passed in then we'd rather they are calculated. // Note update is not recomended anyway... foreach (['sort_name', 'display_name'] as $fieldToNotSet) { unset($existing[$fieldToNotSet]); } $p = array_merge($existing, $apiRequest['params']); return civicrm_api($apiRequest['entity'], 'create', $p); }