$this->_campaignFromClause
);
list($select, $from) = explode(' FROM ', $sql);
- $insertSQL = "
-INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data )
-SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
+ $selectSQL = "
+ SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
FROM {$from}
";
- $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
- $result = CRM_Core_DAO::executeQuery($insertSQL);
- unset($errorScope);
- if (is_a($result, 'DB_Error')) {
+ try {
+ Civi::service('prevnext')->fillWithSql($cacheKey, $selectSQL);
+ }
+ catch (CRM_Core_Exception $e) {
+ // Heavy handed, no? Seems like this merits an explanation.
return;
}
+
// also record an entry in the cache key table, so we can delete it periodically
CRM_Core_BAO_Cache::setItem($cacheKey, 'CiviCRM Search PrevNextCache', $cacheKey);
}