Skip to content
Snippets Groups Projects
Unverified Commit e2c83d99 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #21799 from eileenmcnaughton/refs

Do not find references for empty values
parents 38e4a7e4 eb2a4878
Branches
Tags
No related merge requests found
......@@ -112,21 +112,26 @@ EOS;
*/
public function getReferenceCount($targetDao) {
$targetColumn = $this->getTargetKey();
$params = [
1 => [$targetDao->$targetColumn, 'String'],
];
$sql = <<<EOS
$count = 0;
if ($targetDao->{$targetColumn} !== '' && $targetDao->{$targetColumn} !== NULL) {
$params = [
1 => [$targetDao->{$targetColumn} ?? '', 'String'],
];
$sql = <<<EOS
SELECT count(*)
FROM {$this->getReferenceTable()}
WHERE {$this->getReferenceKey()} = %1
EOS;
$count = CRM_Core_DAO::singleValueQuery($sql, $params);
}
return [
'name' => implode(':', ['sql', $this->getReferenceTable(), $this->getReferenceKey()]),
'type' => get_class($this),
'table' => $this->getReferenceTable(),
'key' => $this->getReferenceKey(),
'count' => CRM_Core_DAO::singleValueQuery($sql, $params),
'count' => $count,
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment