Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.