Php 致命错误:调用非目标代码点火器上的成员函数
我遵循了模型的文档,我不断地发现这个错误,任何帮助都将不胜感激 遇到一个PHP错误 严重性:通知 消息:未定义属性:管理::$File 文件名:files/manage.php 电话号码:14 致命错误:在第14行的/var/www/uisimulator/application/controllers/files/manage.php中对非对象调用成员函数get_files()* 这是我的模型:-位于:application/models/files/file.phpPhp 致命错误:调用非目标代码点火器上的成员函数,php,mysql,codeigniter,Php,Mysql,Codeigniter,我遵循了模型的文档,我不断地发现这个错误,任何帮助都将不胜感激 遇到一个PHP错误 严重性:通知 消息:未定义属性:管理::$File 文件名:files/manage.php 电话号码:14 致命错误:在第14行的/var/www/uisimulator/application/controllers/files/manage.php中对非对象调用成员函数get_files()* 这是我的模型:-位于:application/models/files/file.php class File e
class File extends CI_Model {
var $filename = '';
function __construct() {
parent::__construct();
}
// Return all config files
function get_files() {
$query = $this->db->get('config_files');
return $query->result();
}
function insert_file() {
$this->filename = $this->input->post('filename');
$this->db->insert('config_files', $this);
}
function update_file() {
$this->filename = $this->input->post('filename');
$this->db->update('config_files', $this, array('id' => $this->input->post('id'));
}
}
这是我的控制器:位置:application/controllers/files/manage.php
class File extends CI_Model {
var $filename = '';
function __construct() {
parent::__construct();
}
// Return all config files
function get_files() {
$query = $this->db->get('config_files');
return $query->result();
}
function insert_file() {
$this->filename = $this->input->post('filename');
$this->db->insert('config_files', $this);
}
function update_file() {
$this->filename = $this->input->post('filename');
$this->db->update('config_files', $this, array('id' => $this->input->post('id'));
}
}
类管理扩展CI_控制器{
function __construct() {
parent::__construct();
}
public function index() {
$this->load->model('files/file', TRUE);
$config_files['query'] = $this->File->get_files();
// Load the head section
$this->load->view('head');
// Load the view, passing in the data
$this->load->view('files/index', $configFiles);
// Load Footer
$this->load->view('footer');
}
}
在我的视图中,我有一个简单的循环来显示结果:
<?php foreach ($configFiles as $file) : ?>
<li><?php echo $file['filename'];?></li>
<?php endforeach;?>
试试:
编辑:
$data['configFiles'] = $this->File->get_files();
// Load the head section
$this->load->view('head');
// Load the view, passing in the data
$this->load->view('files/index', $data);
尝试:
编辑:
$data['configFiles'] = $this->File->get_files();
// Load the head section
$this->load->view('head');
// Load the view, passing in the data
$this->load->view('files/index', $data);
在
$this->load->model
方法中将TRUE
作为第二个参数传递的原因是什么
我对CI的理解是,第二个参数是用不同的名称引用模型,而不是它的类
看起来您将类命名为布尔型,这必然会导致某种错误
尝试:
在
$this->load->model
方法中将TRUE
作为第二个参数传递的原因是什么
我对CI的理解是,第二个参数是用不同的名称引用模型,而不是它的类
看起来您将类命名为布尔型,这必然会导致某种错误
尝试:
此代码生成一条记录,但只提供一个表中的字段
function listar_dados_produto($id)
{
$this->db->where('id',$id);
$query = $this->db->get('produtos');
return $query->result();
}
注意:我正在使用activerecord。表produtos正确返回它们的字段,但我需要一个字段
对于另一个名为categorias的表。此代码生成一条记录,但只提供一个表中的字段
function listar_dados_produto($id)
{
$this->db->where('id',$id);
$query = $this->db->get('produtos');
return $query->result();
}
注意:我正在使用activerecord。表produtos正确返回它们的字段,但我需要一个字段
对于另一个名为categorias的表。这使我遇到了另一个错误并超过了最后一个错误。遇到了PHP错误严重性:注意消息:未定义变量:configFiles文件名:files/manage.PHP行号:20我的变量似乎未定义?//从模型$config\u文件['query'获取配置文件]=$this->file->get_files();这使我遇到了另一个错误并超过了上一个错误。遇到了一个PHP错误严重性:注意消息:未定义变量:configFiles Filename:files/manage.PHP行号:20看起来我的变量未定义?//从模型$config_files['query']获取配置文件=$this->file->get_files();$this->File set在哪里?我看不到它在代码中的任何地方被设置。$this->File set在哪里?我看不到它在代码中的任何地方被设置。