用于hooku updateu N()的Drupal批处理API

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用于hooku updateu N()的Drupal批处理API相关的知识,希望对你有一定的参考价值。

This is the Batch API example shown on http://api.drupal.org/api/drupal/developer--hooks--install.php/function/hook_update_N/6.
  1. <?php
  2. // However, for more complex operations that may take a long time,
  3. // you may hook into Batch API as in the following example.
  4. $ret = array();
  5.  
  6. // Update 3 users at a time to have an exclamation point after their names.
  7. // (They're really happy that we can do batch API in this hook!)
  8. if (!isset($sandbox['progress'])) {
  9. $sandbox['progress'] = 0;
  10. $sandbox['current_uid'] = 0;
  11. // We'll -1 to disregard the uid 0...
  12. $sandbox['max'] = db_result(db_query('SELECT COUNT(DISTINCT uid) FROM {users}')) - 1;
  13. }
  14.  
  15. $users = db_query_range("SELECT uid, name FROM {users} WHERE uid > %d ORDER BY uid ASC", $sandbox['current_uid'], 0, 3);
  16. while ($user = db_fetch_object($users)) {
  17. $user->name .= '!';
  18. $ret[] = update_sql("UPDATE {users} SET name = '$user->name' WHERE uid = $user->uid");
  19.  
  20. $sandbox['progress']++;
  21. $sandbox['current_uid'] = $user->uid;
  22. }
  23.  
  24. $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
  25.  
  26. return $ret;
  27. ?>

以上是关于用于hooku updateu N()的Drupal批处理API的主要内容,如果未能解决你的问题,请参考以下文章

Drupal 6.x中的hooku viewsu postu render

aliyun 主机Nginx 上配置Drupal 伪静态

php在后台做代码

android 中有两个列表视图的活动

Drupal 远程代码执行漏洞(CVE-2018-7602)

Drupal 7 列出当前用户所属的有机组