Skip to content

Edit Post does not work after JOIN table #18

@investu

Description

@investu

Hi,
First of all, Thank you for the good lecture :),

Beacause Table posts and categories has same column name "id"
$this->db->order_by('posts.id', 'DESC');
$this->db->join('categories', 'categories.id = posts.category_id');

get_posts METHOD return id is categories.id

so when edit post it is not working properly.
I changed Model

    **$this->db->select('posts.*, posts.id as post_id, categories.*');**
    
    $this->db->order_by('posts.id', 'DESC');
    $this->db->join('categories', 'categories.id = posts.category_id');

and also edit view.php, edit.php to $post['post_id']

Thx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions