[eluser]Richard Schumann[/eluser]
ok lets say you have something like a facebook wall with a lot events. now you wanna add a feature that you can comment a comment and OUTPUT all these events AND comments for each event in a common for-each loop. so that must be a join thing, but everything i tryed just gave me DOUBLE events - with several comments in the fields... OR if i group_by (event.id) just ONE comment - the LAST one - to be more detailed :-)
MYSQL
Code:
table EVENTS : id, value
table COMMENTS: id, event_id, value
so again : i want something like fallowing view:
EVENT1 blabla
COMMENT1 FOR EVENT1 blabla
COMMENT2 FOR EVENT1 blabla
EVENT 2 blabla
COMMENT1 FOR EVENT2 blablabla
EVENT 3 bla bla
COMMENT1 FOR EVENT3 blabla
COMMENT2 FOR EVENT3 blabla
COMMENT3 FOR EVENT3 blabla
COMMENT4 FOR EVENT3 blabla
so my model looks like this right now ( well more complex with more joins, AS, order_by, limit and so on,
but i think - thats the important part for this thread and this problem ?)
Code:
$result = $this
->db
->select('events.id, events.value, comments.id, comments.event_id, comments.value')
->from('events')
->join('comments', 'events.id = comments.event_id', 'left')
->get()
->result_array();
so how to get a result_array what is multi-dimensional maybe and contains then maybe a field COMMENTS what have id, value pairs in it ?
thank you so much again guys.