mysql - Codeigniter - Can only load model in autoload.php -



mysql - Codeigniter - Can only load model in autoload.php -

i'm going crazy because have been using codeigniter ages , cannot seem load model in view.

this have done. model code (models/changelog.php):

<?php class changelog extends ci_model { function __construct() { parent::__construct(); $this->load->database(); } function get_list() { $query = $this->db->get('changelog'); homecoming $query->result(); } } /* location: ./application/models/changelog.php */

this controller (controllers/explore.php):

<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class explore extends ci_controller { public function index() { $this->load->view('include/header'); $this->load->view('home'); $this->load->view('include/footer'); } public function changelog() { $this->load->model('changelog'); $data['changelog_row'] = $this->changelog->get_list(); $this->load->view('include/header'); $this->load->view('explore/changelog', $data); $this->load->view('include/footer'); } } /* location: ./application/controllers/explore.php */

i codeigniter notice telling me message: undefined property: explore::$changelog , php error, fatal error: phone call fellow member function get_list() on non-object.

here did

tried autoload database instead of loading in model tried changing changelog phone call in contorller lowercase checked connection database enabled log file, doesn't tells me new

everything works correctly, maybe it's me beingness little tired, if help me out i'd love :)

after tests found out error in the

$data['changelog_row'] = $this->changelog->get_list();

line of code. have no thought problem is. case sensitivity fine (also tried many combinations of lowercase/uppercase), , if create function different name (e.g. foo()) normal echo within same error referring function.

here screen

something incredible happened: if add together 'changelog' model in autoload.php, seems can load it. going on? used code in many applications without problem.

another test did: if write

public function __construct() { parent:: __construct(); $this->load->model('changelog'); }

in controller or add together parent:: __construct(); in changelog function like

public function changelog() { parent:: __construct(); $this->load->model('changelog'); $data['changelog_data'] = $this->changelog->get_list(); $this->load->view('include/header'); $this->load->view('explore/changelog', $data); $this->load->view('include/footer'); }

it works o_o. why? changed topic title, around inability load model in controller's functions.

ci acting bit unusual that. om unix systems (where filenames case sensitive) have load model case senstive names. in controller should address lowercase, i.e

$this->load->model('changelog'); $this->changelog->getlist();

php mysql database codeigniter model

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -