Lol, GrandFather.
Pyramid schemes do exist, we are by far not one.
your link has this definition of a pyramid scheme:
"A pyramid scheme is a non-sustainable business model that involves the exchange of money primarily for enrolling other people into the scheme, without any product or service being delivered."
We are a product based company, we only take on the best products that are brought to us, we have hundreds of products brought to use every month, the owner of the company only takes on the ones that are the best in their field. For instance, {Revised, not here to convince anyone or sell anything (removed rebuttle)}
Anyhow, I am not here trying to sell anything, I am just trying to populate the initial codings. I already have it to where it bases the rank on the person that referred them. So the problem I am having is only in the initial climbing down the tree. I start with each person ranked and then look at their whole referral tree(everyone in their personal array).
| [reply] |
Try this:
(Monks, please tell me if I am wrong assuming this would work)
UnTested...
use vars qw/$reg_u_tbl $dbh $sth $rows $_autoField $_referField /;
$reg_u_tbl = "registered_users";
$_referField = "referrer_id";
$_autoField = "MemberId";
$_rankField = "ranked1";
$sth = $dbh->prepare("select * from `$reg_u_tbl` where ##RequirementsH
+ere##");
$sth->execute;
while($rows = $sth->fetchrow_hashref()) {
my $thisMembersid = $rows->{$_autoField};
my $referrersid = $rows->{$_referField};
my $rankName = $rows->{$_rankField};
my $startinglevel = 0;
&buildTradRank ($thisMembersid,$referrersid,$rankName,$startinglevel
+);
}
$sth->finish();
sub buildTradRank {
($_rankedid,$_startingid,$_rank,$_level) = @_;
my $_fieldName = $_rank . '_traditional';
$_level++;
$_countLevels++;
$_highLevel = $_level if $_level > $_highLevel;
if($_level == 1) {
my $_addToSearch = "";
} else {
my $_addToSearch = qq~ and `$_rank` = "0"~;
}
$sth2 = $dbh->prepare(qq{select * from `$reg_u_tbl` where `$_refer
+Field` = ?$_addToSearch});
$sth2->execute($_startingid);
while(my $_nregu = $sth2->fetchrow_hashref()) {
if(!$_nregu->{$_fieldName} || ($_nregu->{$_fieldName} && $_nre
+gu->{$_fieldName} != $_rankedid)) {
my $_updated = $dbh->do(qq{update `$reg_u_tbl` set `$_fiel
+dName` = ? where `$_autoField` = ?}, undef, $_rankedid, $_nregu->{$_a
+utoField});
if($_updated) {
$_countAllNewlyAdded++;
} else {
$_countAllNewlyAddedFailures++;
$_dbi_errors .= $DBI::errstr . "\n" if $DBI::errstr;
}
}
if(!$_nregu->{$_rank}) {
my $_countReferred = $dbh->selectrow_array(qq{select count
+(*) from `$reg_u_tbl` where `$_referField` = ? and `$_rank` = "0"}, u
+ndef, $_nregu->{MemberId});
if(!$_countReferred) {
next;
}
# Send back to this routine when it returns it should cont
+inue with the current data, starting it over SHOULD fork a new routin
+e...
&buildTradRank($_rankedid,$_nregu->{$_autoField},$_rank,$_
+level);
}
next;
}
return 1;#Return when finished...
}
By creating one subroutine, you should be able to call it in the middle of it, which should start a new process, with new data and when it returns, then it should continue where it left off... You had it just about right, I only seen an error in your subroutine, you did not add the call to catch the data you passed to the subroutine...
Monks, am I correct in this?
Lee
| [reply] [d/l] |