4 * Description of a one-way link between two entities
6 * This is a generic, soft-foreign key based on a pair of columns (entity_id, entity_table).
8 class CRM_Core_Reference_Dynamic
extends CRM_Core_Reference_Basic
{
10 public function matchesTargetTable($tableName) {
15 * Create a query to find references to a particular record
17 * @param CRM_Core_DAO $targetDao the instance for which we want references
18 * @return CRM_Core_DAO a query-handle (like the result of CRM_Core_DAO::executeQuery)
20 public function findReferences($targetDao) {
21 $refColumn = $this->getReferenceKey();
22 $targetColumn = $this->getTargetKey();
25 1 => array($targetDao->$targetColumn, 'String'),
27 // If anyone complains about $targetDao::getTableName(), then could use
28 // "{get_class($targetDao)}::getTableName();"
29 2 => array($targetDao::getTableName(), 'String'),
34 FROM {$this->getReferenceTable()}
35 WHERE {$refColumn} = %1
36 AND {$this->getTypeColumn()} = %2
39 $daoName = CRM_Core_DAO_AllCoreTables
::getClassForTable($this->getReferenceTable());
40 $result = CRM_Core_DAO
::executeQuery($sql, $params, TRUE, $daoName);