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!

图片转代码服务由CSDN问答提供 功能建议

我正在编写一个php脚本,可以让人们改变他们的drupal网站的主题。 到目前为止,这么好,但最后一件事我无法弄明白。 每次提交表单时,数据库都会更改,但主题不会更改。 显然,我还必须清除缓存。 我在Drupal网站上找到了这个:

&lt;?php include_once'./includes/bootstrap.inc'; druprupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupalal_flush_all_caches(); \ n?&gt;

我应该用这个脚本制作一个小文件'clear.php',每次我要清除缓存时,我应该去这个文件 并清除缓存喊...

但他们是我的问题。 我不知道如何在我的脚本中调用此页面。 我可以创建一个按钮,将用户重定向到此页面,但我喜欢它在一个脚本中。

有什么想法吗? 或者是他们使用php刷新Drupal缓存的其他方法?

提前致谢!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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

相关推荐 更多相似问题