49 $this->_db = sqlite_open(
APP_PATH .
'temp/cache.db');
50 $result = sqlite_query($this->_db,
"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND tbl_name='cache' ");
51 $count = sqlite_fetch_single($result);
54 sqlite_exec($this->_db,
' CREATE TABLE cache (id TEXT, "group" TEXT, value TEXT, lifetime TEXT) ');
67 public function get($id, $group=
'default')
70 $this->_group = $group;
72 $id = addslashes($id);
73 $group = addslashes($group);
75 $id = addslashes($id);
76 $group = addslashes($group);
79 $result = sqlite_query($this->_db,
" SELECT value FROM cache WHERE id='$id' AND \"group\"='$group' AND lifetime>'$lifetime' OR lifetime='undefined' ");
80 return sqlite_fetch_single($result);
92 public function save($value, $lifetime=null, $id=
false, $group=
'default')
100 $lifetime = strtotime($lifetime);
102 $lifetime =
'undefined';
105 $id = addslashes($id);
106 $group = addslashes($group);
107 $value = addslashes($value);
109 $result = sqlite_query($this->_db,
" SELECT COUNT(*) FROM cache WHERE id='$id' AND \"group\"='$group' ");
110 $count = sqlite_fetch_single($result);
115 return sqlite_exec($this->_db,
" UPDATE cache SET value='$value', lifetime='$lifetime' WHERE id='$id' AND \"group\"='$group' ");
118 return sqlite_exec($this->_db,
" INSERT INTO cache (id, \"group\", value, lifetime) VALUES ('$id','$group','$value','$lifetime') ");
130 $group = addslashes($group);
131 return sqlite_exec($this->_db,
" DELETE FROM cache WHERE \"group\"='$group' ");
133 return sqlite_exec($this->_db,
" DELETE FROM cache ");
143 public function remove($id, $group=
'default')
145 $id = addslashes($id);
146 $group = addslashes($group);
148 return sqlite_exec($this->_db,
" DELETE FROM cache WHERE id='$id' AND \"group\"='$group' ");