From e87c8fb711b5454c2a4492248af2e368c004180d Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 19 Jan 2016 15:34:25 +0530 Subject: [PATCH] fix api test break --- CRM/Core/BAO/CustomValueTable.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index 85291f211b..985fa51596 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -430,12 +430,10 @@ class CRM_Core_BAO_CustomValueTable { } $cond = implode(' AND ', $cond); - $limit = ''; + $limit = $orderBy = ''; if (!empty($DTparams['rowCount']) && $DTparams['rowCount'] > 0) { $limit = " LIMIT " . CRM_Utils_Type::escape($DTparams['offset'], 'Integer') . ", " . CRM_Utils_Type::escape($DTparams['rowCount'], 'Integer'); } - - $orderBy = ''; if (!empty($DTparams['sort'])) { $orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($DTparams['sort'], 'String'); } @@ -474,7 +472,9 @@ AND $cond foreach ($select as $tableName => $clauses) { $query = "SELECT SQL_CALC_FOUND_ROWS id, " . implode(', ', $clauses) . " FROM $tableName WHERE entity_id = $entityID {$orderBy} {$limit}"; $dao = CRM_Core_DAO::executeQuery($query); - $result['count'] = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()'); + if (!empty($DTparams)) { + $result['count'] = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()'); + } while ($dao->fetch()) { foreach ($fields[$tableName] as $fieldID) { $fieldName = "custom_{$fieldID}"; -- 2.25.1