继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

hook_cron 在drupal模块中的简单使用

hook_cron 用它来做定时更新是很不错的选择。这里有详细的介绍 http://drupal.org/cron 包括其安全性的介绍。
对于Unix, Linux 来设置更加方便了,定时去执行cron.php文件。
在模块中使用也很简单,

<?php
hook_corn
{
//来执行动作代码块;
}
?>

看看cron的核心代码
Code

developer/hooks/core.php, 第254行

<?php
function hook_cron() {
 
$result = db_query('SELECT * FROM {site} WHERE checked = 0 OR checked
    + refresh < %d'
, time());

  while (
$site = db_fetch_array($result)) {
   
cloud_update($site);
  }
}
?>

评论

ni haoya

ni haoya

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.