getReferenceKey(); $targetColumn = $this->getTargetKey(); $params = array( 1 => array($targetDao->$targetColumn, 'String'), // If anyone complains about $targetDao::getTableName(), then could use // "{get_class($targetDao)}::getTableName();" 2 => array($targetDao::getTableName(), 'String'), ); $sql = <<getReferenceTable()} WHERE {$refColumn} = %1 AND {$this->getTypeColumn()} = %2 EOS; $daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($this->getReferenceTable()); $result = CRM_Core_DAO::executeQuery($sql, $params, TRUE, $daoName); return $result; } /** * @param CRM_Core_DAO $targetDao * * @return array */ public function getReferenceCount($targetDao) { $targetColumn = $this->getTargetKey(); $params = array( 1 => array($targetDao->$targetColumn, 'String'), // If anyone complains about $targetDao::getTableName(), then could use // "{get_class($targetDao)}::getTableName();" 2 => array($targetDao::getTableName(), 'String'), ); $sql = <<getReferenceTable()} WHERE {$this->getReferenceKey()} = %1 AND {$this->getTypeColumn()} = %2 EOS; return array( 'name' => implode(':', array('sql', $this->getReferenceTable(), $this->getReferenceKey())), 'type' => get_class($this), 'table' => $this->getReferenceTable(), 'key' => $this->getReferenceKey(), 'count' => CRM_Core_DAO::singleValueQuery($sql, $params), ); } }