I am developing a module and as part of that I have a function that runs to confirm a transaction. The function creates a manual database connection and uses mysqli commands to set autocommit to false etc. (i.e. I am not using the DB class for this particular function). If the transaction is committed, a number of table rows are inserted and others updated.
The site has database caching enabled and I don’t want to turn this off. However, when the user next accesses a relevant template, the information is not updated (presumably because I didn’t use the DB class to update the database).
Is there a way to stop particular templates from using the database cache?
I was thinking maybe I could enable PHP on the relevant templates and call:
$DB->enable_cache(FALSE)
If this works, would the cache have to be re-enabled at the end of the template?
EDIT: Perhaps it would be better to just delete the cache:
$DB->delete_cache()
Of course, I presume this would delete all cache files, thus decreasing performance for the rest of the site.
Thanks,
Rob
Update:
Rather than put the code in the templates I have added it to the beginning and end of my affected functions (including any functions that use the DB class but return output to templates where that output relies on database information that was updated without using the DB class):
my_function()
{
global $DB;
$DB->enable_cache(FALSE);
$db_conn = mysqli_connect($DB->hostname, $DB->username, $DB->password, $DB->database);
blah, blah blah;
$DB->enable_cache(TRUE);
}
This seems to have worked OK.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.