Please look at this code:
$query = $this->db->query("SELECT * FROM comments c LEFT JOIN users u ON u.user_id = c.user_id");
foreach ($query->result('Comment') as $comment)
{
// $comment holds all data from both tables
}
So, what I want is to have two objects $comment (only with columns from comments table as object properties) and $user for that comment. Is there any simple way to get that?
Please note that this is general question and I need all columns from both tables and sometimes columns in one table can have names as columns in other tables.
I found solution whitch works very fine for me now. Everything what I need is to use PDO.
Here is my code now:
And row2object() helper: