Displaying Data from a Join in Codeigniter
Posted
by
Brad
on Stack Overflow
See other posts from Stack Overflow
or by Brad
Published on 2011-01-15T20:43:24Z
Indexed on
2011/01/15
20:53 UTC
Read the original article
Hit count: 146
I am using a simple join to pull data from two databases. This is the join in the model
function com_control(){
$this->db->select('*');
$this->db->from('comments');
$this->db->join('posts', 'comments.entry_id = posts.id');
$query = $this->db->get();
return $query->result;
}
My desired method of display is going to be in a table so I am starting out to use like this
foreach($comm_control as $row){
$this->table->add_row(
$row->entry_id,
$row->comments.id,
$row->comment,
$row->title
);
}//end of foreach
My problem is the display of data from comments.id. What is the proper format to add the comment.id into the table rows? I need the ID from both tables for display, edit and delete further on in the table. The only display I get at this time for "comment.id" is the word id.
The
Any help would be appreciated.
© Stack Overflow or respective owner