You are here

function _uc_addresses_db_update_address in Ubercart Addresses 5

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

Update an address in the database table.

Parameters

$address The address to add.:

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. If $view is 'edit' run update database function, if 'new' or 'add', run insert database function.

File

./uc_addresses.module, line 1302

Code

function _uc_addresses_db_update_address($address) {

  // Check for problems
  $result = _uc_addresses_db_check_address($address, 'update', false);
  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);
  }
  drupal_set_message(t('The address was updated.'));
  return TRUE;
}