status with status posts

I have the tables user,status and status_post.

User has many status and status may have many status_post.

Now I have a guery that return the name,photo from the user and the status text form the status.

So I have all the information in an array

What is the best solution to take also all the posts per status?


public function getEponumousStatus($param, $type) {

        $return = array();

        $limit = Yii::app()->params['boardlimit'];        

            $mytable = "status";      

        $sql = "SELECT  `st_text`, $mytable.`pr_id` as id,  `st_date` ,

         profile_pict as photo,concat(name,' ', surname) as  display_name

FROM   $mytable,usrs

   WHERE `$mytable`.pr_id=usrs.ID ... ";     

        $command = Yii::app()->db->createCommand($sql);

        $command->bindParam(":type", $type, PDO::PARAM_STR);

        $command->bindParam(":user", $param, PDO::PARAM_STR);

       $return = $command->queryAll();         


        return $return;

    }