用于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.
<?php // However, for more complex operations that may take a long time, // you may hook into Batch API as in the following example. // Update 3 users at a time to have an exclamation point after their names. // (They're really happy that we can do batch API in this hook!) $sandbox['progress'] = 0; $sandbox['current_uid'] = 0; // We'll -1 to disregard the uid 0... $sandbox['max'] = db_result(db_query('SELECT COUNT(DISTINCT uid) FROM {users}')) - 1; } $users = db_query_range("SELECT uid, name FROM {users} WHERE uid > %d ORDER BY uid ASC", $sandbox['current_uid'], 0, 3); while ($user = db_fetch_object($users)) { $user->name .= '!'; $ret[] = update_sql("UPDATE {users} SET name = '$user->name' WHERE uid = $user->uid"); $sandbox['progress']++; $sandbox['current_uid'] = $user->uid; } return $ret; ?>
以上是关于用于hooku updateu N()的Drupal批处理API的主要内容,如果未能解决你的问题,请参考以下文章
Drupal 6.x中的hooku viewsu postu render