Skip to content
Snippets Groups Projects
Commit eb2a4878 authored by Eileen McNaughton's avatar Eileen McNaughton
Browse files

Do not find references for empty values.

parent 28b58696
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