ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilGlobalCacheQueryWrapper.php
Go to the documentation of this file.
1
<?
php
2
require_once(
'./Services/GlobalCache/classes/class.ilGlobalCache.php'
);
3
12
class
ilGlobalCacheQueryWrapper
13
{
14
const
FETCH_TYPE_ASSOC
= 1;
15
const
FETCH_TYPE_OBJECT
= 2;
16
const
MODE_SINGLE
= 1;
17
const
MODE_MULTIPLE
= 2;
21
protected
$query
=
''
;
25
protected
$cache_key
=
''
;
29
protected
$fetch_type
= self::FETCH_TYPE_OBJECT;
33
protected
$mode
= self::MODE_SINGLE;
34
35
42
public
function
__construct
(
$cache_key
,
$query
,
$fetch_type
= self::FETCH_TYPE_OBJECT,
$mode
= self::MODE_SINGLE)
43
{
44
$this->cache_key =
$cache_key
;
45
$this->fetch_type =
$fetch_type
;
46
$this->mode =
$mode
;
47
$this->query =
$query
;
48
}
49
50
54
public
function
get
()
55
{
56
$ilGlobalCache =
ilGlobalCache::getInstance
();
57
if
($ilGlobalCache->isActive()) {
58
$rec = $ilGlobalCache->get($this->cache_key);
59
if
(!$rec) {
60
$rec = $this->getFromDb();
61
$ilGlobalCache->set($this->cache_key, $rec, 600);
62
}
63
}
else
{
64
$rec = $this->getFromDb();
65
}
66
67
return
$rec;
68
}
69
70
74
protected
function
getFromDb()
75
{
76
global
$DIC
;
77
$ilDB
= $DIC[
'ilDB'
];
81
$return = array();
82
$res
=
$ilDB
->query($this->query);
83
switch
($this->
getFetchType
()) {
84
case
self::FETCH_TYPE_OBJECT:
85
while
($rec =
$ilDB
->fetchObject(
$res
)) {
86
$return[] = $rec;
87
}
88
break
;
89
case
self::FETCH_TYPE_ASSOC:
90
while
($rec =
$ilDB
->fetchAssoc(
$res
)) {
91
$return[] = $rec;
92
}
93
break
;
94
}
95
96
if
($this->
getMode
() == self::MODE_SINGLE) {
97
return
$return[0];
98
}
else
{
99
return
$return;
100
}
101
}
102
103
107
public
function
setFetchType
(
$fetch_type
)
108
{
109
$this->fetch_type =
$fetch_type
;
110
}
111
112
116
public
function
getFetchType
()
117
{
118
return
$this->fetch_type
;
119
}
120
121
125
public
function
setMode
(
$mode
)
126
{
127
$this->mode =
$mode
;
128
}
129
130
134
public
function
getMode
()
135
{
136
return
$this->mode
;
137
}
138
}
ilGlobalCacheQueryWrapper\$cache_key
$cache_key
Definition:
class.ilGlobalCacheQueryWrapper.php:25
ilGlobalCacheQueryWrapper\setFetchType
setFetchType($fetch_type)
Definition:
class.ilGlobalCacheQueryWrapper.php:107
ilGlobalCacheQueryWrapper\MODE_MULTIPLE
const MODE_MULTIPLE
Definition:
class.ilGlobalCacheQueryWrapper.php:17
$DIC
global $DIC
Definition:
saml.php:7
ilGlobalCache\getInstance
static getInstance($component)
Definition:
class.ilGlobalCache.php:115
ilGlobalCacheQueryWrapper
Class ilGlobalCacheQueryWrapper.
Definition:
class.ilGlobalCacheQueryWrapper.php:12
ilGlobalCacheQueryWrapper\getMode
getMode()
Definition:
class.ilGlobalCacheQueryWrapper.php:134
ilGlobalCacheQueryWrapper\FETCH_TYPE_ASSOC
const FETCH_TYPE_ASSOC
Definition:
class.ilGlobalCacheQueryWrapper.php:14
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilGlobalCacheQueryWrapper\setMode
setMode($mode)
Definition:
class.ilGlobalCacheQueryWrapper.php:125
ilGlobalCacheQueryWrapper\__construct
__construct($cache_key, $query, $fetch_type=self::FETCH_TYPE_OBJECT, $mode=self::MODE_SINGLE)
Definition:
class.ilGlobalCacheQueryWrapper.php:42
ilGlobalCacheQueryWrapper\$fetch_type
$fetch_type
Definition:
class.ilGlobalCacheQueryWrapper.php:29
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilGlobalCacheQueryWrapper\MODE_SINGLE
const MODE_SINGLE
Definition:
class.ilGlobalCacheQueryWrapper.php:16
php
ilGlobalCacheQueryWrapper\getFetchType
getFetchType()
Definition:
class.ilGlobalCacheQueryWrapper.php:116
ilGlobalCacheQueryWrapper\$query
$query
Definition:
class.ilGlobalCacheQueryWrapper.php:21
ilGlobalCacheQueryWrapper\$mode
$mode
Definition:
class.ilGlobalCacheQueryWrapper.php:33
ilGlobalCacheQueryWrapper\FETCH_TYPE_OBJECT
const FETCH_TYPE_OBJECT
Definition:
class.ilGlobalCacheQueryWrapper.php:15
Services
GlobalCache
classes
class.ilGlobalCacheQueryWrapper.php
Generated on Thu Jan 16 2025 19:02:22 for ILIAS by
1.8.13 (using
Doxyfile
)