Welcome Guest, Not a member yet? Register   Sign In
Multiple calls to model in controller fails
#1

[eluser]novice32[/eluser]
Not sure why this happens, but if I run the below, it fails (specifically $rs_client should not be null). But if, say, I comment out
Code:
$this->Client_model->RemoveTrial($client_id);
then, it executes successfully ($rs_client is not null).

Are there constraints with calling/referencing a model in subsequent calls within a single Controller class??

/***** CONTROLLER *****/
Code:
function start() {

        $this->load->model('Client_model', '', TRUE);
        $rs =  $this->Client_model->GetActiveClients();

        foreach ($rs as $client_rec) {

            $client_id = $client_rec['ClientID'];
            $plan_start_date = $client_rec['ClientPlanStartDate'];
            $trial_end_date = $client_rec['ClientTrialEndDate'];

            //convert date strings to time for comparison
            $trial_end_date = strtotime($trial_end_date);
            $current_date = strtotime(date("Y-m-d"));

            $trial_start_next_day = strtotime($client_rec['ClientTrialStartDate']." +1 day");
           if ($current_date == $trial_end_date) {
                 $this->_email_user_trial_expired($client_id);
                 $this->Client_model->RemoveTrial($client_id);
              
             } elseif ($current_date == $trial_start_next_day) {                
                $this->_email_user_welcome_nextday($client_id);

            }
        }
    }  

   function _email_user_trial_expired($client_id = NULL) {
      
       if ($client_id == NULL) {
            return false;
        }

        $rs_client =  $this->Client_model->GetClientByID($client_id);  
        ....
    }
    
     function _email_user_welcome_nextday($client_id = NULL) {
        
        if ($client_id == NULL) {
            return false;
        }

        $this->load->model('Client_model', '', TRUE);      
        $rs_client = $this->Client_model->GetClientByID($client_id);  

        if (!$rs_client) {
            echo 'rs_client is empty!<br/>';
        }
        else {
            echo 'rs_client IS NOT empty!<br/>';
        }
        return;
    }


Messages In This Thread
Multiple calls to model in controller fails - by El Forum - 12-04-2010, 02:18 PM
Multiple calls to model in controller fails - by El Forum - 12-04-2010, 04:04 PM
Multiple calls to model in controller fails - by El Forum - 12-04-2010, 06:49 PM
Multiple calls to model in controller fails - by El Forum - 12-06-2010, 05:19 AM
Multiple calls to model in controller fails - by El Forum - 12-06-2010, 08:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB