1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00
movim_ynh/sources/app/models/cache/CacheDAO.php

64 lines
1.5 KiB
PHP
Raw Normal View History

2016-03-15 16:28:38 +01:00
<?php
namespace modl;
class CacheDAO extends SQL {
2016-03-29 14:12:33 +02:00
function get($key) {
2016-03-15 16:28:38 +01:00
$this->_sql = '
select * from cache
2016-03-29 14:12:33 +02:00
where
2016-03-15 16:28:38 +01:00
session = :session
and name = :name';
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
$this->prepare(
2016-03-29 14:12:33 +02:00
'Cache',
2016-03-15 16:28:38 +01:00
array(
2016-03-29 14:12:33 +02:00
'session' => $this->_user,
2016-03-15 16:28:38 +01:00
'name' => $key
)
);
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
return $this->run('Cache', 'item');
}
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
function set(Cache $cache) {
$this->_sql = '
update cache
set data = :data,
timestamp = :timestamp
where session = :session
and name = :name';
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
$this->prepare(
2016-03-29 14:12:33 +02:00
'Cache',
2016-03-15 16:28:38 +01:00
array(
2016-03-29 14:12:33 +02:00
'session' => $this->_user,
2016-03-15 16:28:38 +01:00
'data' => $cache->data,
'timestamp' => $cache->timestamp,
'name' => $cache->name
)
);
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
$this->run('Cache');
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
if(!$this->_effective) {
$this->_sql = '
insert into cache
(session, name, data, timestamp)
values (:session, :name, :data, :timestamp)';
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
$this->prepare(
2016-03-29 14:12:33 +02:00
'Cache',
2016-03-15 16:28:38 +01:00
array(
2016-03-29 14:12:33 +02:00
'session' => $this->_user,
2016-03-15 16:28:38 +01:00
'name' => $cache->name,
'data' => $cache->data,
'timestamp' => $cache->timestamp
)
);
2016-03-29 14:12:33 +02:00
2016-03-15 16:28:38 +01:00
return $this->run('Cache');
}
}
}