Cannot load a model in codeigniter -
i failed load model controller
this controller file, article.php:
<?php class article extends ci_controller { function show($id) { //id'ye gore getir $this->load->model('articles_model'); $parameter = $this->articles_model>getarticle($id); $this->my_template->build('article_view', $parameter); } } ?>
this model file, articles_model.php:
<?php class articles_model extends ci_model { function __construct() { // call model constructor parent::__construct(); } function getarticle($id) { parent::model(); $query = $this->db->get_where('articles', array('id' => $id)); $data['articles'] = $query->result(); return $data; $query->free_result(); } } ?>
just add, tried load autoloader, still no chance, assume wrong model, or whole system broke.
up: models loads without problems, if put echo in __construct function, works, however, cannot call getarticle function. geez
up: did it! according http://grasshopperpebbles.com/codeigniter/codeigniter-call-to-a-member-function-on-a-non-object/
i used $ci =& get_instance(); , called function $ci->articles_model->getarticle($id) , called function
it should be,
$ci =&get_instance(); $ci->load->model('articles_model'); $parameter = $ci->articles_model>getarticle($id);
Comments
Post a Comment