Ui/DataProvider/Grid/Transaction/Query.php
protected function getQueryItems()
    {
        /* this is primary query builder, not extender */
        $result = parent::getQueryItems();

        /* define tables aliases for internal usage (in this method) */
        $asAccCred = self::AS_ACC_CREDIT;
        $asAccDeb = self::AS_ACC_DEBIT;
        $asDwnlCred = self::AS_DWNL_CRED;
        $asDwnlDeb = self::AS_DWNL_DEB;

        /* LEFT JOIN prxgt_dwnl_customer as debit */
        $tbl = $this->resource->getTableName(self::E_DWNL_CUST);
        $as = $asDwnlDeb;
        $cols = [
            self::A_MLM_ID_DEBIT => EDownline::A_MLM_ID
        ];
        $cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccDeb . '.' . EAccount::A_CUST_ID;
        $result->joinLeft([$as => $tbl], $cond, $cols);

        /* LEFT JOIN prxgt_dwnl_customer as credit */
        $tbl = $this->resource->getTableName(self::E_DWNL_CUST);
        $as = $asDwnlCred;
        $cols = [
            self::A_MLM_ID_CREDIT => EDownline::A_MLM_ID
        ];
        $cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccCred . '.' . EAccount::A_CUST_ID;
        $result->joinLeft([$as => $tbl], $cond, $cols);

        /* return  result */
        return $result;
    }
protected function getQueryItems()
    {
        /* this is primary query builder, not extender */
        $result = parent::getQueryItems();

        /* define tables aliases for internal usage (in this method) */
        $asAccCred = self::AS_ACC_CREDIT;
        $asAccDeb = self::AS_ACC_DEBIT;
        $asDwnlCred = self::AS_DWNL_CRED;
        $asDwnlDeb = self::AS_DWNL_DEB;

        /* LEFT JOIN prxgt_dwnl_customer as debit */
        $tbl = $this->resource->getTableName(self::E_DWNL_CUST);
        $as = $asDwnlDeb;
        $cols = [
            self::A_MLM_ID_DEBIT => EDownline::A_MLM_ID
        ];
        $cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccDeb . '.' . EAccount::A_CUST_ID;
        $result->joinLeft([$as => $tbl], $cond, $cols);

        /* LEFT JOIN prxgt_dwnl_customer as credit */
        $tbl = $this->resource->getTableName(self::E_DWNL_CUST);
        $as = $asDwnlCred;
        $cols = [
            self::A_MLM_ID_CREDIT => EDownline::A_MLM_ID
        ];
        $cond = "$as." . EDownline::A_CUSTOMER_REF . '=' . $asAccCred . '.' . EAccount::A_CUST_ID;
        $result->joinLeft([$as => $tbl], $cond, $cols);

        /* return  result */
        return $result;
    }
protected function getQueryItems ( ) { /* this is primary query builder, not extender */ $ result = parent :: getQueryItems ( ) ; /* define tables aliases for internal usage (in this method) */ $ asAccCred = self :: AS_ACC_CREDIT ; $ asAccDeb = self :: AS_ACC_DEBIT ; $ asDwnlCred = self :: AS_DWNL_CRED ; $ asDwnlDeb = self :: AS_DWNL_DEB ; /* LEFT JOIN prxgt_dwnl_customer as debit */ $ tbl = $ this -> resource -> getTableName ( self :: E_DWNL_CUST ) ; $ as = $ asDwnlDeb ; $ cols = [ self :: A_MLM_ID_DEBIT => EDownline :: A_MLM_ID ] ; $ cond = "$as." . EDownline :: A_CUSTOMER_REF . '=' . $ asAccDeb . '.' . EAccount :: A_CUST_ID ; $ result -> joinLeft ( [ $ as => $ tbl ] , $ cond , $ cols ) ; /* LEFT JOIN prxgt_dwnl_customer as credit */ $ tbl = $ this -> resource -> getTableName ( self :: E_DWNL_CUST ) ; $ as = $ asDwnlCred ; $ cols = [ self :: A_MLM_ID_CREDIT => EDownline :: A_MLM_ID ] ; $ cond = "$as." . EDownline :: A_CUSTOMER_REF . '=' . $ asAccCred . '.' . EAccount :: A_CUST_ID ; $ result -> joinLeft ( [ $ as => $ tbl ] , $ cond , $ cols ) ; /* return  result */ return $ result ; }
SELECT
...
FROM
`prxgt_acc_transaction` AS `pat`
LEFT JOIN `prxgt_acc_account` AS `paa_db` ON
paa_db.id = pat.debit_acc_id
LEFT JOIN `customer_entity` AS `ce_db` ON
ce_db.entity_id = paa_db.customer_id
LEFT JOIN `prxgt_acc_account` AS `paa_cr` ON
paa_cr.id = pat.credit_acc_id
LEFT JOIN `customer_entity` AS `ce_cr` ON
ce_cr.entity_id = paa_cr.customer_id
LEFT JOIN `prxgt_acc_type_asset` AS `pata` ON
pata.id = paa_db.asset_type_id
LEFT JOIN `prxgt_dwnl_customer` AS `dwnlDebit` ON
dwnlDebit.customer_ref = paa_db.customer_id
LEFT JOIN `prxgt_dwnl_customer` AS `dwnlCredit` ON
dwnlCredit.customer_ref = paa_cr.customer_id
SELECT ... FROM prxgt_acc_transaction AS pat LEFT JOIN prxgt_acc_account AS paa_db ON paa_db . id = pat . debit_acc_id LEFT JOIN customer_entity AS ce_db ON ce_db . entity_id = paa_db . customer_id LEFT JOIN prxgt_acc_account AS paa_cr ON paa_cr . id = pat . credit_acc_id LEFT JOIN customer_entity AS ce_cr ON ce_cr . entity_id = paa_cr . customer_id LEFT JOIN prxgt_acc_type_asset AS pata ON pata . id = paa_db . asset_type_id LEFT JOIN prxgt_dwnl_customer AS dwnlDebit ON dwnlDebit . customer_ref = paa_db . customer_id LEFT JOIN prxgt_dwnl_customer AS dwnlCredit ON dwnlCredit . customer_ref = paa_cr . customer_id