Author Topic: Help with Code  (Read 730 times)

0 Members and 1 Guest are viewing this topic.

Offline php_nooby82Topic starter

  • Irregular
  • Posts: 14
    • View Profile
Help with Code
« on: November 06, 2009, 05:51:57 AM »
Ok, here is the code, then I'll tell you what I am trying to do:

Model People:

Code: [Select]
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)

Code: [Select]
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:

Code: [Select]
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
Code: [Select]
$cid = $dmc->start_cycle($profile["id"], 1);
Here  is what I tried (and I tried several other things) but I keep getting an error.

Code: [Select]
If ($no_gifts == 1)
{
$cid = $dmc->start_cycle($profile["id"], 8);
}
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
Code: [Select]
$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:

Code: [Select]
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!


Offline ram4nd

  • Enthusiast
  • Posts: 451
  • Gender: Male
  • Web is awsome!
    • View Profile
    • Browse Tutorials
Re: Help with Code
« Reply #1 on: November 09, 2009, 03:48:20 PM »
It's not important, but about what framework are we talking about. And I was being sarcastic.

Offline php_nooby82Topic starter

  • Irregular
  • Posts: 14
    • View Profile
Re: Help with Code
« Reply #2 on: November 09, 2009, 04:11:03 PM »
Sorry, I thought this was an area just for Zend.

This is the Zend Framework.