function delete_key($key, $bundle_id = FALSE, $session_id = NULL, $site_id = 1, $invalidate = 0)
{
$this->db->where('key_name', $key)->where('site_id', $site_id);
// match a specific bundle
if ($bundle_id) {
$this->db->where('bundle_id', $bundle_id);
}
if (!is_null($session_id)) {
$this->db->where('session_id', $session_id);
if ($session_id !== '_global') {
// make sure we only delete the user's variable
$this->db->limit(1);
}
}
// get matching key(s)
$query = $this->db->select('id, site_id, key_name, key_label, session_id, bundle_id')->get('stash');
if ($query->num_rows() > 0) {
if ($this->delete_cache($query->result(), TRUE, $invalidate)) {
// deleted, now remove the key from the internal key cache
$cache_key = $key . '_' . $bundle_id . '_' . $site_id . '_' . $session_id;
if (isset(self::$keys[$cache_key])) {
unset(self::$keys[$cache_key]);
}
return TRUE;
}
}
return FALSE;
}