:)
I have a problem with relationships in codeigniter , I'm doing a small blog.
the problem is that I need in the post by the user ID called the USERNAME that created the post .
but I can not do it step my code , I hope you can help me
controller
public function show($post = NULL)
{
$this->load->model('post_model', 'posts_model');
$this->load->helper('url');
$postid = $this->uri->segment(4);
$post = $this->posts_model->get_by('id', $postid);
$this->data = array(
'title' => 'Posts',
'subtitle' => 'Post',
'navClass' => 'tofront blue-bar',
'subnavClass' => 'toback blue-bar',
'isfab' => true,
'message' => $this->session->flashdata('message'),
'posts_call' => $post,
'current' => current_url(),
'sidebar' => true,
);
$this->session->set_userdata('last_page', current_url());
$this->theme->render('post/show', $this->data);
}
model
class Post_model extends SP_Model { public $belongs_to = array( 'post' => array( 'primary_key' => 'post_author' ) ); }
DB:
thanks in advance! :D