From c5d6e9b54bd624156ee2f2ae5eb995e82182a5ae Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 22 Jun 2016 02:20:44 +0530 Subject: [PATCH] --CRM-16189, fixed sql by removing civicrm_option_value join, instead used option value in where clause --- CRM/Financial/BAO/FinancialAccount.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index db721d44c1..defff9a1ba 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -291,11 +291,11 @@ WHERE cft.id = %1 public static function getDeferredFinancialType() { $deferredFinancialType = array(); $query = "SELECT ce.entity_id, cft.name FROM civicrm_entity_financial_account ce -INNER JOIN civicrm_option_value cv ON ce.account_relationship = cv.value -INNER JOIN civicrm_option_group cg ON cg.id= cv.option_group_id AND cg.name = 'account_relationship' INNER JOIN civicrm_financial_type cft ON ce.entity_id = cft.id -WHERE `entity_table` = 'civicrm_financial_type' AND cv.name = 'Deferred Revenue Account is' AND cft.is_active = 1"; - $dao = CRM_Core_DAO::executeQuery($query); +WHERE ce.entity_table = 'civicrm_financial_type' AND ce.account_relationship = %1 AND cft.is_active = 1"; + $deferredAccountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Deferred Revenue Account is' ")); + $queryParams = array(1 => array($deferredAccountRel, 'Integer')); + $dao = CRM_Core_DAO::executeQuery($query, $queryParams); while ($dao->fetch()) { $deferredFinancialType[$dao->entity_id] = $dao->name; } -- 2.25.1