function views_content_cache_update_set in Views content cache 6.2
Same name and namespace in other branches
- 7.3 views_content_cache.module \views_content_cache_update_set()
Create one or more update records for the given object.
Parameters
object $object: The object for which the update is occurring. Example: a $node object.
string $object_type: A string identifier that other modules can use to identify the type of object passed to them. Example: 'node'.
int $timestamp: A timestamp to use for the update record. Optional.
Return value
boolean Returns TRUE if one or more update records were written. FALSE if none were written.
6 calls to views_content_cache_update_set()
- views_content_cache_comment in ./
views_content_cache.module - Implementation of hook_comment().
- views_content_cache_nodeapi in ./
views_content_cache.module - Implementation of hook_nodeapi().
- views_content_cache_nodequeue_add in ./
views_content_cache.module - Implementation of hook_nodequeue_add().
- views_content_cache_nodequeue_remove in ./
views_content_cache.module - Implementation of hook_nodequeue_remove().
- views_content_cache_nodequeue_sort_alter in ./
views_content_cache.module - Implementation of hook_nodequeue_sort_alter().
File
- ./
views_content_cache.module, line 115 - Views content cache cache.
Code
function views_content_cache_update_set($object, $object_type, $timestamp = NULL) {
$update = FALSE;
$timestamp = isset($timestamp) ? $timestamp : time();
if ($cids = views_content_cache_id_generate($object, $object_type)) {
foreach ($cids as $cid) {
if (!empty($cid)) {
$update = TRUE;
$mapped = views_content_cache_id_record($cid);
// Remove any update records that match this cid.
$where = array();
$args = array();
foreach ($mapped as $key_id => $key_value) {
if (isset($key_value)) {
$where[] = "{$key_id} = " . db_placeholders($key_value, 'varchar');
$args[] = $key_value;
}
else {
$where[] = "{$key_id} IS NULL";
}
}
if (!empty($where)) {
$where = implode(' AND ', $where);
db_query("DELETE FROM {views_content_cache} WHERE {$where}", $args);
}
$mapped['timestamp'] = $timestamp;
drupal_write_record('views_content_cache', $mapped);
}
}
}
return $update;
}