*/
public function findReferences($targetDao) {
$targetColumn = $this->getTargetKey();
+ $select = 'id';
+ // CRM-19385: Since id is removed, return all rows for cache tables.
+ if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($this->getReferenceTable(), 'id')) {
+ $select = '*';
+ }
$params = array(
- 1 => array($targetDao->$targetColumn, 'String')
+ 1 => array($targetDao->$targetColumn, 'String'),
);
$sql = <<<EOS
-SELECT id
+SELECT {$select}
FROM {$this->getReferenceTable()}
WHERE {$this->getReferenceKey()} = %1
EOS;
public function getReferenceCount($targetDao) {
$targetColumn = $this->getTargetKey();
$params = array(
- 1 => array($targetDao->$targetColumn, 'String')
+ 1 => array($targetDao->$targetColumn, 'String'),
);
$sql = <<<EOS
-SELECT count(id)
+SELECT count(*)
FROM {$this->getReferenceTable()}
WHERE {$this->getReferenceKey()} = %1
EOS;
'type' => get_class($this),
'table' => $this->getReferenceTable(),
'key' => $this->getReferenceKey(),
- 'count' => CRM_Core_DAO::singleValueQuery($sql, $params)
+ 'count' => CRM_Core_DAO::singleValueQuery($sql, $params),
);
}
+
}