1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-23 09:23:09 +02:00

MDL-90 moodlelib: Introducing get_cache_flag() - gets a row from cache_flags table

Useful if you intend to use cache_flags as a session
table. (Oops! Did I reveal my cunning plans?)
This commit is contained in:
martinlanghoff 2008-02-27 02:57:33 +00:00
parent a668c80845
commit a489cf72cb

@ -770,6 +770,27 @@ function get_cache_flags($type, $changedsince=NULL) {
return $cf;
}
/**
* Get volatile flags
*
* @param string $type
* @param string $name
* @param int $changedsince
* @return records array
*
*/
function get_cache_flag($type, $name, $changedsince=NULL) {
$type = addslashes($type);
$name = addslashes($name);
$sqlwhere = 'flagtype=\'' . $type . '\' AND name=\'' . $name . '\' AND expiry >= ' . time();
if ($changedsince !== NULL) {
$changedsince = (int)$changedsince;
$sqlwhere .= ' AND timemodified > ' . $changedsince;
}
return get_field_select('cache_flags', 'value', $sqlwhere);
}
/**
* Set a volatile flag