codeigniter模型未加载--500内部服务器错误

时间:2014-02-24 13:45:41

标签: php codeigniter

我有一台机器,模型根本没有加载,它一直有500内部服务器错误

这是我的控制器

<?php
/*
 *
 * Controller to activate new subscriber with details from partner initiated activation
 *
 */

class PartnerActivation extends CI_Controller
{
    /*
     *
     * Constructor that will call automatically
     *
     * Helper Loading for url and form which is inbuilt feature of code igniter we are using
     *
     *
     */
    public function __construct()

    {
        parent::__construct();

        $this->load->helper(array('url','form'));   
    }

    public function index()
    {

        if(isset($_POST['invoicedate']))
        {
            $invoicedate = $_POST['invoicedate'];
        }
        else 
        {
            $invoicedate = '';
        }


        if(isset($_POST['deviceid']))
        {
            $deviceid = $_POST['deviceid'];
        }
        else 
        {
            $deviceid = '';
        }

            //save all these fields to a table, and do a http request
            $this->load->model('activation_model','activationmodel',TRUE);
            $this->activationmodel->addPartnerActivation($deviceid,$invoicedate);


    }
}

这是我的模型 - 文件名是Activation_model.php

<?php
class Activation_model extends CI_Model
{


/*
 * partner initiated activation, store this in the database
 */
public function addPartnerActivation($deviceid,$invoicedate)
{
    //never reaches here
        return true;
}

}

磨削我的齿轮

4 个答案:

答案 0 :(得分:0)

您必须加载模型,如:

$this->load->model('Activation_model');然后调用类似$this->Activation_model->addPartnerActivation()的函数。然后它会工作..

答案 1 :(得分:-1)

替换

 $this->load->model('activation_model','activationmodel',TRUE);
 to
 $this->load->model(array('activation_model','activationmodel'));

希望有所帮助

答案 2 :(得分:-1)

在控制器中: -

        Change :-
            $this->activationmodel->addPartnerActivation($deviceid,$invoicedate);

        To :- 
            $this->activation_model->addPartnerActivation($deviceid,$invoicedate);

在调用addPartnerActivation时,您提供了错误的模型名称。

希望它能帮助你:)

答案 3 :(得分:-3)

无论如何,我自己修好了,进入apache日志看看发生了什么,显然函数有';'然后定义,这就产生了像这样的致命错误

[2014年2月24日星期一14:04:44] [错误] [客户端122.176.100.181] PHP致命错误:非抽象方法activation_model :: updatePartnerActivation()必须包含/ var / www / api / application /中的body第157行的models / activation_model.php

抱歉,感谢帮助人员,@ Justinwood让我在任何地方检查日志