【发布时间】:2018-01-24 22:21:33
【问题描述】:
错误代码
遇到了 PHP 错误
严重性:通知
消息:未定义属性:CI_Loader::$yamaha_model
文件名:控制器/Yamaha.php
行号:12
回溯:
文件: /home/billionp/domains/billionproonline.com/public_html/bpp_8/application/controllers/Yamaha.php 行:12 函数:_error_handler
文件: /home/billionp/domains/billionproonline.com/public_html/bpp_8/index.php 行:295 功能:require_once
致命错误:在非对象上调用成员函数 product() /home/billionp/domains/billionproonline.com/public_html/bpp_8/application/controllers/Yamaha.php 在第 12 行
遇到了 PHP 错误
严重性:错误
消息:在非对象上调用成员函数 product()
文件名:控制器/Yamaha.php
行号:12
回溯:
控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Yamaha extends CI_Controller {
public function index(){
$template = array(
'title' => 'YAMAHA',
'heading' => 'My Heading',
'message' => 'My Message'
);
$contents['row'] = $this->load->yamaha_model->product();
// $contents['row'] = $this->yamaha_model->product();
$contents['cart_session'] = $this->session->userdata('cart_session');
$template['content'] = $this->load->view('yamaha',$contents,TRUE);
$this->load->view('template',$template);
}
}
型号:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Yamaha_model extends CI_Model {
function __construct() {
parent::__construct();
}
function product(){
return $i = $this->db->select('*')->from('yamaha')->get()->result();
}
function product_detail($id){
return $i = $this->db->select('*')->from('yamaha')->where('product_id',$id)->get()->row();
}
}
【问题讨论】:
-
你试过在构造函数中加载模型吗?
标签: php jquery html css codeigniter