public function getFamilySosaListAtGeneration($gen){
        if(!$this->is_setup) return array();
        if(!$this->sosa_fam_list_by_gen)
            $this->sosa_fam_list_by_gen = array();
        
        if($gen){
            if(!isset($this->sosa_fam_list_by_gen[$gen])){
                $this->sosa_fam_list_by_gen[$gen] = Database::prepare(
                    'SELECT s1.majs_sosa AS sosa, f_id AS fam'.
                    ' FROM `##families`'.
                    ' INNER JOIN `##maj_sosa` AS s1 ON (`##families`.f_husb = s1.majs_i_id AND `##families`.f_file = s1.majs_gedcom_id)'.
                    ' INNER JOIN `##maj_sosa` AS s2 ON (`##families`.f_wife = s2.majs_i_id AND `##families`.f_file = s2.majs_gedcom_id)'.
                    ' WHERE s1.majs_sosa + 1 = s2.majs_sosa'.
                    ' AND s1.majs_gedcom_id= :tree_id AND s1.majs_user_id=:user_id'.
                    ' AND s2.majs_gedcom_id= :tree_id AND s2.majs_user_id=:user_id'.
                    ' AND s1.majs_gen = :gen'.
                    ' ORDER BY s1.majs_sosa ASC'
                    )
                    ->execute(array(
                        'tree_id' => $this->tree->getTreeId(),
                        'user_id' => $this->user->getUserId(),
                        'gen' => $gen
                    ))
                    ->fetchAssoc();
            }
            return $this->sosa_fam_list_by_gen[$gen];
        }
        return array();
    }