我在模型中有以下代码:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Membership_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
public function register_user($info)
{
if(isset($info))
{
$data = array(
'fullname' => $info['fullname'] ,
'mobile' => $info['mobile'] ,
'telephone' => $info['home'] ,
'username' => $info['username'] ,
'password' => $info['password'] ,
'email' => $info['email'] ,
'member_type' => $info['memberType']
);
$this->db->insert('users', $data);
}
}
}
我在控制器中以这种方式调用它:
$info = array('fullname' => $fullname , 'mobile' => $mobile, 'home' => $home,
'username' => $username, 'password' => $password,
'memberType' => $memberType, 'email' => $email );
$this->membershipModel->register_user($info);
尽管如此,我收到了这个错误:
遇到PHP错误
严重性:注意
消息:未定义属性:Membership :: $ db
文件名:core / Model.php
行号:51
知道这意味着什么吗?的问候,
答案 0 :(得分:1)
在CodeIgniter中,类和方法名称区分大小写:
$this->membershipModel->register_user($info);
应该阅读......
$this->Membership_model->register_user($info);
注意强>
确保将模型文件命名为:membership_model.php
,如CodeIgniter文档中所指定。