You are here

function _uc_addresses_db_update_address in Ubercart Addresses 6

Same name and namespace in other branches
  1. 5.2 uc_addresses.module \_uc_addresses_db_update_address()
  2. 5 uc_addresses.module \_uc_addresses_db_update_address()

Update an address in the database table.

Parameters

$address The address to add.:

$silent boolean TRUE if no warnings should be displayed to the user.:

Return value

A boolean that is TRUE if the address was added, FALSE otherwise.

1 call to _uc_addresses_db_update_address()
uc_addresses_get_address_form_submit in ./uc_addresses.module
Handle the form submit for adding a new address or editing an existing address.

File

./uc_addresses.module, line 1359

Code

function _uc_addresses_db_update_address($address, $silent = FALSE) {

  // Check for problems
  $result = _uc_addresses_db_check_address($address, 'update', $silent);
  if (!$result) {
    return FALSE;
  }

  // We're set to go
  db_query("UPDATE {uc_addresses} SET " . "first_name = '%s', " . "last_name = '%s', " . "phone = '%s', " . "company = '%s', " . "street1 = '%s', " . "street2 = '%s', " . "city = '%s', " . "zone = %d, " . "postal_code = '%s', " . "country = %d, " . "address_name = '%s', " . "modified = %d " . "WHERE aid = %d", $address->first_name, $address->last_name, $address->phone, $address->company, $address->street1, $address->street2, $address->city, $address->zone, $address->postal_code, $address->country, $address->address_name, time(), $address->aid);

  // Update the default address, if necessary
  if ($address->is_default) {
    db_query("UPDATE {uc_addresses_defaults} SET aid = %d WHERE uid = %d", $address->aid, $address->uid);
  }
  if (!$silent) {
    drupal_set_message(t('The address was updated.'));
  }
  return TRUE;
}