XAF
XAF

Reputation: 1472

Fatal error: while loading codeigniter model

I am using a function from codeigniter controller which calls a model called payment plan for me to use. I have been using this method all over the place but this is the first time I am getting a problem with it. The error is Fatal error: Call to a member function createPaymentPlan() on a non-object in I am not sure what I am doing wrong but here is the code.

            $this->load->model("payment_plan");
            $this->load->model("fee_page");

            foreach ($itemdetails as $itemdetail) {
                $Amount = $itemdetail["borrowOrInvestAmount"];
                $currency = $itemdetail["Currency"];
                $Interest = $itemdetail["Interest"];
                $Loantime = (isset($data['Loantime']) && $data['Loantime'] > 0) ? $data['Loantime'] : $itemdetail["Loantime"];
                $start_date = $data["start_date"];
                $payment_term = $data["payment_term"];                   

                $paymenPlanSingle = $this->payment_plan->createPaymentPlan($Amount, $currency, $Interest, $Loantime, $start_date, $payment_term);
                $countOfElements = count($paymenPlanSingle);
             }

The second it reaches payment_plan it crashes even though I loaded the controller already.

Upvotes: 0

Views: 48

Answers (2)

Masnad Nihit
Masnad Nihit

Reputation: 1996

Everything looks okay. Most of the time this problem is occurs due to a loading of controller before. Check if you are loading any controller before or not, if you are, please load the model "payment_plan" before it.

Upvotes: 1

Artur
Artur

Reputation: 101

Check the controller does not overwrite var

$this->payment_plan

if you can show the controller and model payment_plan

Upvotes: 0

Related Questions