use Traits\DAOActionTrait;
/**
- * Fields to return. Defaults to all non-custom fields `['*']`.
+ * Fields to return. Defaults to all standard (non-custom, non-extra) fields `['*']`.
*
- * The keyword `"custom.*"` selects all custom fields. So to select all core + custom fields, select `['*', 'custom.*']`.
+ * The keyword `"custom.*"` selects all custom fields (except those belonging to multi-record custom field sets). So to select all standard + custom fields, select `['*', 'custom.*']`.
+ *
+ * Multi-record custom field sets are represented as their own entity, so join to that entity to get those custom fields.
*
* Use the dot notation to perform joins in the select clause, e.g. selecting `['*', 'contact.*']` from `Email::get()`
* will select all fields for the email + all fields for the related contact.
$onlyCount = $this->getSelect() === ['row_count'];
if (!$onlyCount) {
+ // Typical case: fetch various fields.
$query = new Api4SelectQuery($this);
$rows = $query->run();
\CRM_Utils_API_HTMLInputCoder::singleton()->decodeRows($rows);
$result->exchangeArray($rows);
+
// No need to fetch count if we got a result set below the limit
if (!$this->getLimit() || count($rows) < $this->getLimit()) {
- $result->rowCount = count($rows) + $this->getOffset();
- $getCount = FALSE;
+ if ($getCount) {
+ $result->setCountMatched(count($rows) + $this->getOffset());
+ $getCount = FALSE;
+ }
+ else {
+ // Set rowCount for backward compatibility.
+ $result->rowCount = count($rows) + $this->getOffset();
+ }
}
}
+
if ($getCount) {
$query = new Api4SelectQuery($this);
- $result->rowCount = $query->getCount();
+ $result->setCountMatched($query->getCount());
}
}