Php 我可以在库方法codeigniter中使用model classe的方法吗
可能重复: 我尝试在我的CI web中使用外部库。我指的是这些链接 为了让这一切顺利进行 但我得到了下面的错误消息Php 我可以在库方法codeigniter中使用model classe的方法吗,php,codeigniter,Php,Codeigniter,可能重复: 我尝试在我的CI web中使用外部库。我指的是这些链接 为了让这一切顺利进行 但我得到了下面的错误消息 A PHP Error was encountered Severity: Notice Message: Undefined property: Dataloading::$load Filename: libraries/dataloading.php Line Number: 28 我尝试的是从库中加载组合框的数据。 这是库类的代码 <?php if ( !
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Dataloading::$load
Filename: libraries/dataloading.php
Line Number: 28
我尝试的是从库中加载组合框的数据。
这是库类的代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dataloading {
public function __construct() {
}
public function index()
{
}
public function loadcombo(){
$this->load->model('dataOperateModel');
//Calling the getcombo_titel() function to get the arr of titles. Model already loaded.
$arrStates = $this->dataOperateModel->getcombo_titel();
//Getting the final array in the form which I will be using for the form helper to create a dropdown.
foreach ($arrStates as $job_name) {
$arrFinal[] = $job_name->title;
}
$data['job_name'] = $arrFinal;
$data['main_content']='home/welcome_message';
//Passing $data to the view, so that we can get the states as an array inside the view.
$this->load->view('layout',$data);
}
}
这是欢迎课的代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct() {
parent::__construct();
//this condition will check whether user has logged in, otherwise
//he will be redirect to login
if (!$this->session->userdata('logged_in'))
{
redirect('admin/admin_login');
}
// $this->load->model('dataOperateModel');
}
public function index()
{
//$this->load->view('welcome_message');
$this->load->library('dataloading');
$this->dataloading->loadcombo();
//$this->loadcombo();
}
}
谁能解释一下我在哪里犯的错误。为了使用Codeigniter核心和库,您需要加载Codeigniter实例
$this->ci =& get_instance();
然后你可以参考如下
$this->ci->load(.....)
最好检查一下谢谢艾哈迈德。我在userguid中遗漏了上述概念。