diff --git a/library/Metier/Partenaires/MBanques.php b/library/Metier/Partenaires/MBanques.php index 48dae0ef..1ecacabb 100644 --- a/library/Metier/Partenaires/MBanques.php +++ b/library/Metier/Partenaires/MBanques.php @@ -63,9 +63,22 @@ class Metier_Partenaires_MBanques */ protected $conn; + /** + * Logger + * @var \Monolog\Logger + */ + protected $logger; + + /** + * Banque + */ public function __construct() { $this->conn = Zend_Registry::get('doctrine'); + + if (Zend_Registry::isRegistered('logger')) { + $this->logger = Zend_Registry::get('logger'); + } } /** @@ -76,15 +89,25 @@ class Metier_Partenaires_MBanques public function getInfoBanque($codeBanque) { $result = array(); - $sql = "SELECT bdfFibCodeEtab, bdfFibCodeSituation, bdfFibDenom40, - bdfFibDenom10, bdfFibCodeActivite, bdfFibCodeOrganeRepr, bdfFibDateAgrement, * - bdfFibDateRetraitAgr, bdfFibDateFinDiffus, bdfFibAdresse1, bdfFibAdresse2, - bdfFibAdresse3, CP, Ville, bdfFibCodeEtabAbsorb, bdfFibOptionIdInvar, - bdfFibDateOptIdInvar FROM insee.BDF_Etabs WHERE bdfFibCodeEtab=:code LIMIT 0,1"; - $stmt = $this->conn->prepare($sql); - $stmt->bindValue('code', $codeBanque); - $stmt->execute(); - if ($stmt->rowCount() > 0) { + + $stmtNb = 0; + try { + $sql = "SELECT bdfFibCodeEtab, bdfFibCodeSituation, bdfFibDenom40, + bdfFibDenom10, bdfFibCodeActivite, bdfFibCodeOrganeRepr, bdfFibDateAgrement, * + bdfFibDateRetraitAgr, bdfFibDateFinDiffus, bdfFibAdresse1, bdfFibAdresse2, + bdfFibAdresse3, CP, Ville, bdfFibCodeEtabAbsorb, bdfFibOptionIdInvar, + bdfFibDateOptIdInvar FROM insee.BDF_Etabs WHERE bdfFibCodeEtab=:code LIMIT 0,1"; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('code', $codeBanque); + $stmt->execute(); + $stmtNb = $stmt->rowCount(); + } catch (\Doctrine\DBAL\DBALException $e) { + if ($this->logger !== null) { + $this->logger->error($e->getMessage()); + } + } + + if ($stmtNb > 0) { $result = $stmt->fetch(\PDO::FETCH_ASSOC); } @@ -103,19 +126,28 @@ class Metier_Partenaires_MBanques $tabBanque = $this->getInfoBanque($codeBanque); $tabTel = $this->getTelGuichet($codeBanque, $codeGuichet); - $sql = "SELECT bdfFibCodeEtab, bdfFibCodeGuichet, bdfFibCodeSituation AS guichetCodeSituation, - bdfFibDenom40 AS guichetDenom40, bdfFibDenom20 AS guichetDenom20, bdfFibCodeEtabCible, - bdfFibCodeGuichetRepr, bdfFibCodeGeoInsee, bdfFibCodeLocalite1, bdfFibCodeLocalite2, - bdfFibComptoirBDF, bdfFibAdresse1 AS guichetAdresse1, bdfFibAdresse2 AS guichetAdresse2, - bdfFibAdresse3 AS guichetAdresse3, CP AS guichetCP, Ville AS guichetVille, - bdfFibAdresseSWIFT, bdfFibDateOuverture, bdfFibDateFermeture, bdfFibDateFinDiffus, - bdfFibCodeRoutage, bdfFibLibelleRIB, bdfFibNatureGuichet, bdfFibCodeAchOperBDF, - bdfFibNomComptoirBDF FROM WHERE bdfFibCodeEtab=:banque AND bdfFibCodeGuichet=:guichet LIMIT 0,1"; - $stmt = $this->conn->prepare($sql); - $stmt->bindValue('banque', $codeBanque); - $stmt->bindValue('guichet', $codeGuichet); - $stmt->execute(); - if ($stmt->rowCount() > 0) { + $stmtNb = 0; + try { + $sql = "SELECT bdfFibCodeEtab, bdfFibCodeGuichet, bdfFibCodeSituation AS guichetCodeSituation, + bdfFibDenom40 AS guichetDenom40, bdfFibDenom20 AS guichetDenom20, bdfFibCodeEtabCible, + bdfFibCodeGuichetRepr, bdfFibCodeGeoInsee, bdfFibCodeLocalite1, bdfFibCodeLocalite2, + bdfFibComptoirBDF, bdfFibAdresse1 AS guichetAdresse1, bdfFibAdresse2 AS guichetAdresse2, + bdfFibAdresse3 AS guichetAdresse3, CP AS guichetCP, Ville AS guichetVille, + bdfFibAdresseSWIFT, bdfFibDateOuverture, bdfFibDateFermeture, bdfFibDateFinDiffus, + bdfFibCodeRoutage, bdfFibLibelleRIB, bdfFibNatureGuichet, bdfFibCodeAchOperBDF, + bdfFibNomComptoirBDF FROM WHERE bdfFibCodeEtab=:banque AND bdfFibCodeGuichet=:guichet LIMIT 0,1"; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('banque', $codeBanque); + $stmt->bindValue('guichet', $codeGuichet); + $stmt->execute(); + $stmtNb = $stmt->rowCount(); + } catch (\Doctrine\DBAL\DBALException $e) { + if ($this->logger !== null) { + $this->logger->error($e->getMessage()); + } + } + + if ($stmtNb > 0) { $result = $stmt->fetch(\PDO::FETCH_ASSOC); } @@ -130,12 +162,21 @@ class Metier_Partenaires_MBanques public function getTelGuichet($codeBanque, $codeGuichet) { $result = array(); - $sql = "SELECT Tel, Fax FROM insee.Mandel_banques WHERE CodeB=:banque AND CodeG=:guichet LIMIT 0,1"; - $stmt = $this->conn->prepare($sql); - $stmt->bindValue('banque', $codeBanque); - $stmt->bindValue('guichet', $codeGuichet); - $stmt->execute(); - if ($stmt->rowCount() > 0) { + $stmtNb = 0; + try { + $sql = "SELECT Tel, Fax FROM insee.Mandel_banques WHERE CodeB=:banque AND CodeG=:guichet LIMIT 0,1"; + $stmt = $this->conn->prepare($sql); + $stmt->bindValue('banque', $codeBanque); + $stmt->bindValue('guichet', $codeGuichet); + $stmt->execute(); + $stmtNb = $stmt->rowCount(); + } catch (\Doctrine\DBAL\DBALException $e) { + if ($this->logger !== null) { + $this->logger->error($e->getMessage()); + } + } + + if ($stmtNb > 0) { $result = $stmt->fetch(\PDO::FETCH_ASSOC); }