model
public function getPost(){
$this->db->select('post_title', 'post_auth', 'post_content');
$this->db->from('post');
$query = $this->db->get();
return $query->result_array();
}
controller
public function index(){
$this->load->model('swmodel');
$data['posts'] = $this->swmodel->getPost();
$this->load->view('dashBoard', $data);
}
How can I transfer data in my view?
Honestly I can't say you why, but for some reason in CodeIgniter 3 you have to store the result or return of your function in a variable and then that variable assign it within the array based value you pass to your view as $this->load->view('dashBoard', $data);.
You need to check does exist a view called dashBoard? and where is it?
So you can try with something like:
public function index() {
$this->load->model('posts_model');
// Get your posts, store them in $posts.
$posts = $this->posts_model->getPost();
// Assign your $posts to your $data.
$data['posts'] = $posts;
// Pass your $data when you load the view.
$this->load->view('dashBoard', $data);
}
And then in your view you can easily access to the passed data as $posts.
# dashBoard.php
<?php var_dump($posts); ?>