I was coding in a custom page which is expected to interact with zen-cart database. I included all the necessary php files in my custom page. I also have my own table 'job' which update from time to time.
global $db;
global $zc_cache;
$job_row = $globalHelper->getJob(1);
var_dump($job_row);
$today = date("Y-m-d H:i:s", strtotime(date("d.m.Y H:i:s")));
$query = "UPDATE job SET processedon='" . $today . "', status= 4 WHERE id = 1";
$db->Execute($query);
$job_row = $globalHelper->getJob(1);
var_dump($job_row);
unset($job_row);
To my surprise, running the 3rd query does not give me the updated data, rather the same one before the 2nd query. Also tried $zc_cache->sql_cache_flush_cache(); but no use! I switched off cache from configure.php. Can anyone tell me the reason behind this?
I got the same problem and I hope the following researches I did could help a bit:
I checked the queryFactory class code and it seems that the $db->Execute is some kind of wrapper of the $db->query function. And the $db->query will read query result from a $queryCache object if the query was cached previously.
the $db->query function just completely ignores the $zf_cache parameter in the $db->Execute function and it doesn't have any parameter to control if or not to read cache at all.
the $queryCache is an instance of class query_cache, and the $zc_cache is an instance of class cache
these two classes just has no business with each other, I assume that is why the $zc_cache->sql_cache_flush_cache() doesn't work.
the $db->query only do fresh query if the $queryCache object is not set. I guess you have to switch off the cache in config to make it "not set".
and if you still want global cache but just need no cache on a few of special queries, I guess you could go the most old fashion way, use mysql_query();
It sounds stupid, but I was too lazy to find a better solution, and that's what I am doing.
grrrrrrrrrrr