duangu4980 2011-03-08 09:05
浏览 43
已采纳

清除drupal缓存 - php脚本

I'm writing a php script which will enable people to change the theme of their drupal website. So far, so good but one last thing I couldn't figure out. Every time when I submit the form, the database is changed but the theme doesn't change. Apparently, I have to clear the cache as well. I found this on the Drupal website:

<?php include_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_flush_all_caches(); ?>

I should make a little file 'clear.php' with this script, and every time I want to clear the cache, I should go to this file and the cache shout be cleared...

But their is my problem. I don't know how to call this page in my script. Sure I can make a button which will redirect the user to this page, but I'ld like it in one script.

Any idea's? Or are their other ways to flush the Drupal cache using php?

Thanks in advance!

  • 写回答

4条回答 默认 最新

  • dsh1956 2011-03-08 09:46
    关注

    Tadaa, did it :)

    Just paste this piece op php in my script:

    $deletecachesql = "DELETE FROM cache"; $deletecachequery = mysql_query($deletecachesql) or die ("error").mysql_error(); $deletecacheresult = mysql_fetch_array($deletecachequery);

    The script does clear the cache, but I'm not sure it's a good thing to do. The website also told me to delete:

    • DELETE FROM cache;
    • DELETE FROM cache_menu;
    • DELETE FROM cache_filters;
    • DELETE FROM cache_page;
    • DELETE FROM watchdog;

    Is it a wise thing to do? To clear (delete) the cache like this?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?