Can this task be done a better way?

This is a discussion on Can this task be done a better way? within the PHP Language forums, part of the PHP Programming Forums category; I have an IQ of a donkey, I'm sure the below code can be done a different/more intelligent ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-27-2007
qwertycat@googlemail.com
 
Posts: n/a
Default Can this task be done a better way?

I have an IQ of a donkey, I'm sure the below code can be done a
different/more intelligent way. It should download headers in chunks
of 5000, rather than all 2 million in one go:

$Newsgroup_Data = $NNTP->selectGroup($Newsgroup_Name);

$First_Article_Number = $Newsgroup_Data["first"];
$Last_Article_Number = $Newsgroup_Data["last"];

$Articles_To_Download = $Last_Article_Number - $First_Article_Number;

while($First_Article_Number <= $Newsgroup_Data["last"])
{
$Last_Article_Number = $First_Article_Number + 4999;
$Articles = $NNTP->getOverview($First_Article_Number,
$Last_Article_Number);
$First_Article_Number = $First_Article_Number + 5000;

// do something with the headers here

unset($Articles);
}

Reply With Quote
  #2 (permalink)  
Old 09-28-2007
Jerry Stuckle
 
Posts: n/a
Default Re: Can this task be done a better way?

qwertycat@googlemail.com wrote:
> I have an IQ of a donkey, I'm sure the below code can be done a
> different/more intelligent way. It should download headers in chunks
> of 5000, rather than all 2 million in one go:
>
> $Newsgroup_Data = $NNTP->selectGroup($Newsgroup_Name);
>
> $First_Article_Number = $Newsgroup_Data["first"];
> $Last_Article_Number = $Newsgroup_Data["last"];
>
> $Articles_To_Download = $Last_Article_Number - $First_Article_Number;
>
> while($First_Article_Number <= $Newsgroup_Data["last"])
> {
> $Last_Article_Number = $First_Article_Number + 4999;
> $Articles = $NNTP->getOverview($First_Article_Number,
> $Last_Article_Number);
> $First_Article_Number = $First_Article_Number + 5000;
>
> // do something with the headers here
>
> unset($Articles);
> }
>


What's wrong with what you have?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:04 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0