Browse Source

- Rename 'key' to 'name' to prevent errors in MySQL

pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
1aa21c6f2e
  1. 4
      app/models/cache/Cache.php
  2. 14
      app/models/cache/CacheDAO.php
  3. 6
      system/Cache.php

4
app/models/cache/Cache.php

@ -4,7 +4,7 @@ namespace modl;
class Cache extends ModlModel{
public $session;
public $key;
public $name;
public $data;
public $timestamp;
@ -13,7 +13,7 @@ class Cache extends ModlModel{
{
"session" :
{"type":"string", "size":64, "mandatory":true, "key":true },
"key" :
"name" :
{"type":"string", "size":32, "mandatory":true, "key":true },
"data" :
{"type":"text", "mandatory":true },

14
app/models/cache/CacheDAO.php

@ -8,13 +8,13 @@ class CacheDAO extends ModlSQL {
select * from cache
where
session = :session
and key = :key';
and name = :name';
$this->prepare(
'Cache',
array(
'session' => $session,
'key' => $key
'name' => $key
)
);
@ -27,7 +27,7 @@ class CacheDAO extends ModlSQL {
set data = :data,
timestamp = :timestamp
where session = :session
and key = :key';
and name = :name';
$this->prepare(
'Cache',
@ -35,7 +35,7 @@ class CacheDAO extends ModlSQL {
'session' => $cache->session,
'data' => $cache->data,
'timestamp' => $cache->timestamp,
'key' => $cache->key
'name' => $cache->name
)
);
@ -44,14 +44,14 @@ class CacheDAO extends ModlSQL {
if(!$this->_effective) {
$this->_sql = '
insert into cache
(session, key, data, timestamp)
values (:session, :key, :data, :timestamp)';
(session, name, data, timestamp)
values (:session, :name, :data, :timestamp)';
$this->prepare(
'Cache',
array(
'session' => $cache->session,
'key' => $cache->key,
'name' => $cache->name,
'data' => $cache->data,
'timestamp' => $cache->timestamp
)

6
system/Cache.php

@ -85,9 +85,7 @@ class Cache
*/
private function write_cache($key, $object)
{
//$cache_key = $this->login.':'.$key;
$data = str_replace("'", "\\'", base64_encode(gzcompress(serialize($object))));
//$md5 = md5($data);
$time = date(DATE_ISO8601, time());
$cd = new \modl\CacheDAO();
@ -95,7 +93,7 @@ class Cache
$c->session = $this->login;
$c->data = $data;
$c->key = $key;
$c->name = $key;
$c->timestamp = $time;
$cd->set($c);
@ -106,8 +104,6 @@ class Cache
*/
private function read_cache($key)
{
//$cache_key = $this->login.':'.$key;
$cd = new \modl\CacheDAO();
$var = $cd->get($this->login, $key);

Loading…
Cancel
Save