Helper/Scheme.php
private function getCfgParamsByRanks()
    {
        /* aliases and tables */
        $asParams = 'pbhcp';
        $asRank = 'pbhr';
        $tblParams = $this->resource->getTableName(CfgParam::ENTITY_NAME);
        $tblRank = $this->resource->getTableName(Rank::ENTITY_NAME);
        // FROM prxgt_bon_hyb_cfg_param pbhcp
        $query = $this->conn->select();
        $query->from([$asParams => $tblParams]);
        // LEFT JOIN prxgt_bon_hyb_rank pbhr ON pbhcp.rank_id = pbhr.id
        $on = "$asParams." . CfgParam::A_RANK_ID . "=$asRank." . Rank::A_ID;
        $cols = [Rank::A_CODE];
        $query->joinLeft([$asRank => $tblRank], $on, $cols);
        // $sql = (string)$query;
        $entries = $this->conn->fetchAll($query);
        $result = [];
        foreach ($entries as $entry) {
            $rankCode = $entry[Rank::A_CODE];
            $rankScheme = $entry[CfgParam::A_SCHEME];
            $result[$rankCode][$rankScheme] = $entry;
        }
        return $result;
    }
private function getCfgParamsByRanks()
    {
        /* aliases and tables */
        $asParams = 'pbhcp';
        $asRank = 'pbhr';
        $tblParams = $this->resource->getTableName(CfgParam::ENTITY_NAME);
        $tblRank = $this->resource->getTableName(Rank::ENTITY_NAME);
        // FROM prxgt_bon_hyb_cfg_param pbhcp
        $query = $this->conn->select();
        $query->from([$asParams => $tblParams]);
        // LEFT JOIN prxgt_bon_hyb_rank pbhr ON pbhcp.rank_id = pbhr.id
        $on = "$asParams." . CfgParam::A_RANK_ID . "=$asRank." . Rank::A_ID;
        $cols = [Rank::A_CODE];
        $query->joinLeft([$asRank => $tblRank], $on, $cols);
        // $sql = (string)$query;
        $entries = $this->conn->fetchAll($query);
        $result = [];
        foreach ($entries as $entry) {
            $rankCode = $entry[Rank::A_CODE];
            $rankScheme = $entry[CfgParam::A_SCHEME];
            $result[$rankCode][$rankScheme] = $entry;
        }
        return $result;
    }
Get all ranks configuration parameters to create map for forced customers.

SELECT
pbhcp.*,
pbhr.code
FROM prxgt_bon_hyb_cfg_param pbhcp
LEFT JOIN prxgt_bon_hyb_rank pbhr
ON pbhcp.rank_id = pbhr.id

@return array [$rankCode => [$scheme=>[$data], ...], ...]