I can not generate the view of the posts in CodeIgniter

3

I follow this video:

link

Clicking on the individual posts does not load my view and I get this error:

  

"An uncaught Exception was encountered

     

Type: Error

     

Message: Call to undefined method Post :: getPostById ()

     

Filename:   C: \ xampp \ htdocs \ application \ application \ controllers \ article.php

     

Line Number: 11

     

Backtrace:

     

File: C: \ xampp \ htdocs \ application \ index.php Line: 315 Function:   require_once "

It says it does not recognize the getPostById () method. Will I have to load a library?

In this repository I have the files:

link

    
asked by Felipe Pino 01.09.2016 в 21:31
source

1 answer

2

It is necessary that you load the model inside the Controller .

public function post ($id ='')
{
    $this->load->model('post');
    $fila = $this->post->getPostById($id);
}

If your files contain classes, they must contain uppercase, in your case, change the name from post.php to Post.php and add model or m . Example: Post_m.php or Post_model.php .

    
answered by 01.02.2017 в 19:13