private function UcAddressesAddressBook::loadOne in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 class/UcAddressesAddressBook.class.php \UcAddressesAddressBook::loadOne()
 
Loads a single address from the database if not already loaded.
No database call is done in these cases:
- Address is already loaded;
 - All addresses are already loaded.
 
@access private
Parameters
int $type: Type of the argument given, can be the address id (BY_AID) or the address nickname (BY_NAME).
mixed $arg: Either the address id or the address nickname.
Return value
void
Throws
3 calls to UcAddressesAddressBook::loadOne()
- UcAddressesAddressBook::deleteOne in class/
UcAddressesAddressBook.class.php  - Deletes one address.
 - UcAddressesAddressBook::getAddressById in class/
UcAddressesAddressBook.class.php  - Get an address by ID.
 - UcAddressesAddressBook::getAddressByName in class/
UcAddressesAddressBook.class.php  - Get an address by it's nickname.
 
File
- class/
UcAddressesAddressBook.class.php, line 799  - Contains the UcAddressesAddressBook class.
 
Class
- UcAddressesAddressBook
 - The address book class
 
Code
private function loadOne($type, $arg) {
  // Reasons to skip out early.
  if ($this->allLoaded) {
    return;
  }
  if (!$this
    ->isOwned()) {
    return;
  }
  if ($type == self::BY_AID && isset($this->addresses[$arg])) {
    return;
  }
  if ($type == self::BY_NAME && $this
    ->findByName($arg)) {
    return;
  }
  // If we're going to save an address, we'll need to know about
  // possible name collisions and what the current default
  // addresses are.
  if ($this->performanceHint == self::PERF_HINT_LOAD_ALL) {
    $this
      ->loadAll();
    return;
  }
  // Read the database. Note that we ensure that this requested
  // address is in this address book by including $uid in the
  // query.
  if ($type == self::BY_AID) {
    $result = db_select('uc_addresses')
      ->condition('uid', $this->uid)
      ->condition('aid', $arg)
      ->fields('uc_addresses')
      ->execute();
  }
  else {
    $result = db_select('uc_addresses')
      ->condition('uid', $this->uid)
      ->condition('address_name', $arg)
      ->fields('uc_addresses')
      ->execute();
  }
  $this
    ->dbResultToAddresses($result);
}