From: Matthew M. <ma...@tu...> - 2007-02-05 13:48:06
|
Verdon, One method would be to to limit the select results. For example, 1.0's conversion script pulls data in batches, converts the batch, then loads the next page. The batch number is incremented and continues until out of results. A better solution my be to break from the API and use a select join: SELECT mod_users.user_id FROM mod_users, mod_cstmembers_members WHERE expiryDate < $today AND mod_cstmembers_members.owner = mod_users.user_id I would use getCol for the results. Then I would manually delete on the results, foreach ($results as $user_id) { $GLOBALS['core']->query("DELETE mod_groups WHERE user_id=$user_id and group_id=$group_id"); } I haven't tried it personally, but I believe mysql 4.0 allows delete joins so you could skip the select part. This is all from the top of my head so testing might be necessary :) Good luck, Matt On Sun, 2007-02-04 at 16:31 -0500, Verdon Vaillancourt wrote: > Hi, > > I'm trying to cobble together something kind of customized to do some > maintenance on a phpws 0.10.2 site and am running into timeout > errors. I'm hoping someone might be able to suggest an alternative > method for me. > > The error is > PHP Fatal error: Maximum execution time of 30 seconds exceeded in / > home/user/public_html/dev/en/lib/pear/DB/mysql.php on line 316 > > The goal of the script is that I have a table with member profiles > that include an expiration date. I need a script that can look at > that table, find the expired users, then look up the corresponding > user and remove them from a couple groups. Eventually, this script > will get run via cron. I am just getting started... > > <?php > > require_once("/home/user/public_html/dev/en/conf/config.php"); > define('PHPWS_SOURCE_DIR', $source_dir); > require_once PHPWS_SOURCE_DIR . 'security.php'; > require_once PHPWS_SOURCE_DIR . 'core/Core.php'; > require_once PHPWS_SOURCE_DIR . 'mod/users/class/Users.php'; > require_once PHPWS_SOURCE_DIR . 'mod/users/class/Groups.php'; > > $GLOBALS['core'] =& new PHPWS_Core(NULL, NULL); > > $today = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d"), > date("Y"))); > > /* first get the array of expired members */ > $expiredMembers = $GLOBALS["core"]->sqlSelect > ("mod_cstmembers_members", "expiryDate", $today, NULL, "<", NULL, > NULL, NULL, NULL, TRUE); > /* then loop through them */ > foreach ($expiredMembers as $member){ > /* get the user_id */ > $user_id = PHPWS_User::getUserId($member['owner']); > if ($user_id) { > /* remove them from the groups */ > $group_id = 1; > PHPWS_User_Groups::removeGroupFromUser($user_id, $group_id); > } > } > > ?> > > Thanks, > verdon -- Matthew McNaney Electronic Student Services Appalachian State University http://phpwebsite.appstate.edu |