Multiply Select from 3 tables

Hello, sorry for bad eng. How i make query from 3 tables and return custom array, example my old code: ```php function GetAllCourses() { global $DBH, $settings; $result = $DBH->query("SELECT, l.sectionid, s.title as 'sectiontitle', s.createdtime, s.closedtime, l.instructorid, l.title, l.videoid, l.presentationid, l.freeaccess, FROM {$settings['dbprefix']}lectures l, {$settings['dbprefix']}sections s, {$settings['dbprefix']}instructors i WHERE l.sectionid = AND l.instructorid ="); $result->setFetchMode(PDO::FETCH_ASSOC); $object = array();

    while($row = $result->fetch()) 
        $object['allcount'] = $i;
        $object[$row['section_id']]['free'] = $row['free_access'];
        $object[$row['section_id']]['title'] = $row['section_title'];
        $object[$row['section_id']]['created_time'] = $row['created_time'];
        $object[$row['section_id']]['closed_time'] = $row['closed_time'];
        $object[$row['section_id']]['author'] = $row['name'];
        $object[$row['section_id']]['lectures'][$i] = array('id' => $row['id'], 'instructor' => $row['name'], 'title' => $row['title'], 'video_id' => $row['video_id'], 'presentation_id' => $row['presentation_id'], 'free_access' => $row['free_access']);
    return $object;

``` In NEW array key is a value $row['section_id'] from SQL result. How i can rewrite this on phalcon? Pls Help

You can use raw sql like you have above following this example:

Instead of returning the Resultset like in the example, you can set it into a variable like $list and do a loop to set the $object array like you want.