php_nooby82 Posted November 6, 2009 Share Posted November 6, 2009 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 More sharing options...
ram4nd Posted November 9, 2009 Share Posted November 9, 2009 It's not important, but about what framework are we talking about. And I was being sarcastic. Link to comment https://forums.phpfreaks.com/topic/180533-help-with-code/#findComment-954335 Share on other sites More sharing options...
php_nooby82 Posted November 9, 2009 Author Share Posted November 9, 2009 Sorry, I thought this was an area just for Zend. This is the Zend Framework. Link to comment https://forums.phpfreaks.com/topic/180533-help-with-code/#findComment-954354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.