/** * @throws DataBackendException * @return Agency[] * @see DataBackend::getAgenciesForBank() */ public function getAgenciesForBank(Bank $bank) { try { $stmt = $this->statementContainer->prepare("SELECT {$this->agencyAttributes} FROM {$this->prefix}agency a\n WHERE bank = :bankID AND id != :mainAgency"); $agencies = array(); $stmt->execute(array(":bankID" => $bank->getBankID(), ":mainAgency" => $bank->getMainAgency()->getID())); foreach ($stmt->fetchAll() as $agencyResult) { $agencies[] = $this->getAgencyObject($bank, $agencyResult); } $stmt->closeCursor(); return $agencies; } catch (\PDOException $e) { $stmt->closeCursor(); throw new DataBackendIOException($e->getMessage(), 0, $e); } catch (MissingAttributesDataBackendIOException $e) { $stmt->closeCursor(); throw new \LogicException($e); } }
/** * @return bool */ public function isMainAgency() { return $this->bank->getMainAgency() === $this; }