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条)

报告相同问题?

悬赏问题

  • ¥15 无源定位系统的时差估计误差标准差
  • ¥15 请问这个代码哪里有问题啊
  • ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库
  • ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
  • ¥15 openpcdet自制数据集评估bev精度和3d精度相同
  • ¥15 excel 上下按钮 显示行
  • ¥20 云卓h12pro 数传问题