I created a comments system in my app which is now attached to my articles->view. One of the features of the comments controller is to be able to allow users to respond to a comment (one level) and being able to create many children comments for a particular comment. Everything is connected thru parent_id.
Right now, when I open an article I use foreach $comments as $comment to retrieve all comments related to the article and in articles_controller.php I assign the $comments variable to find all comments related to the article.
What is the best way to get the children comments of $comment and display it on my view?
The way I am approaching it is to have a function that returns a list of children comments based on $comments->id and display it under $comment per figure below... This seems to be time consuming as a call will be made to this function(ie. childrenComments($id)) for each comment and can definitely bog down the server.
Does anyone know of a better way to use the parent_id relation and save some CPU time?

thank you all for your help.
