From 4f8baa757df924a994718b03e450a9df74b71448 Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Fri, 11 Mar 2022 15:08:46 +0000 Subject: [PATCH] Add countFetched and countMatched outputs to API4 AJAX --- CRM/Api4/Page/AJAX.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CRM/Api4/Page/AJAX.php b/CRM/Api4/Page/AJAX.php index 64edf46f44..4816ea9c97 100644 --- a/CRM/Api4/Page/AJAX.php +++ b/CRM/Api4/Page/AJAX.php @@ -142,6 +142,12 @@ class CRM_Api4_Page_AJAX extends CRM_Core_Page { } unset($vals['rowCount']); $vals['count'] = $result->count(); + $vals['countFetched'] = $result->countFetched(); + if (in_array('row_count', $params['select'] ?? [])) { + // We can only return countMatched (whose value is independent of LIMIT clauses) if row_count was in the select. + $vals['countMatched'] = $result->count(); + } + return $vals; } -- 2.25.1