Jump to content

Help with Code


php_nooby82

Recommended Posts

Ok, here is the code, then I'll tell you what I am trying to do:

 

Model People:

 

public function create_by_array($data)
{
$profile = $this->profile_data($this->insert($data));

$dmc = new Default_Model_Cycle();
$dmt = new Default_Model_Tree();

$cid = $dmc->start_cycle($profile["id"], 1);

$icycle = $dmc->get_newest_cycle($profile["inviter"]);

$dmt->add_to_next_open_slot($icycle["id"], $cid);
}

 

Model Cycles: (I changed this one to just pid and made a new one for aid since I don't want it doing this both times, but that didn't work either)

 

public function start_cycle($pid, $aid)
{
	$data = array(
		'pid' => $pid,
		'aid' => $aid,
	);

	$cid = $this->insert($data);

	$dmt = new Default_Model_Tree();
	$dmt->create_tree($pid, $cid);
	return $cid;
}

 

Model Gift:

 

public function count_gifts_in_cycle($cid)
{
$results = $this->fetchAll($this
->select()
->where('cid_from = ?', $cid)
->where('received_date is not ?', new Zend_Db_Expr('NULL')));
return sizeof($results);
}

------------------------------

 

Ok, using the count_gifts_in_cycle function I am trying to put an if statement in the create_by_array function that will change the 1 in

$cid = $dmc->start_cycle($profile["id"], 1);

 

Here  is what I tried (and I tried several other things) but I keep getting an error.

 

If ($no_gifts == 1)
{
$cid = $dmc->start_cycle($profile["id"], ;
}
else
{
$cid = $dmc->start_cycle($profile["id"], 1);
}

 

I declared no_gifts and added dmg = Default_Model_Gift but it will not work. I think it is because

$cid

is declared for something else, but I tried changing it to $nid and made everything the same, but that didn't work either. Hopefully someone can see what I am doing wrong? Or tell me a better way of doing it.

 

Oh, and I just found a function that uses the start_cycle too, so maybe I should change both for it to work? Not sure, but here is the code for that:

 

Model People:

 

public function create($u,$p)
{
	$data = array(
		"username" => $u,
		"pass" => $p
	);
	$pid = $this->insert($data);

	$dmc = new Default_Model_Cycle();
	$dmc->start_cycle($pid, 1);
}

 

Thanks for any help!

 

 

Link to comment
https://forums.phpfreaks.com/topic/180533-help-with-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.