From: jitendrapurohit Date: Tue, 19 Jan 2016 10:04:25 +0000 (+0530) Subject: fix api test break X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e87c8fb711b5454c2a4492248af2e368c004180d;p=civicrm-core.git fix api test break --- 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}";