Can I cross join to tables using phalcon query builder?

43 views Asked by At

I have 2 tables that use the 3rd table's id as their primary key id. They look like this

Accounts Table

id
1

GNCC

accountsID
1

Payments

accountsID
1

Currently, I'm getting the data that I need from the GNCC table by inner joining it with the accounts table and the Payments table with the matching IDs, however, there are some instances where there is no record of an account id on the GNCC table, but it is on the Payments table, but because I'm inner joining the GNCC table with the accounts table, those records who are not on the GNCC table but are on the Payments table, get lost. Because of this, I probably need to full join the GNCC table with the accounts table and I was wondering if Phalcon's query builder had a similar join like that because I couldn't find any in their documentation.


$builder = $this->modelsManager->createBuilder()
            ->columns([
                'creditFee' => '(SELECT SUM(p.sum) FROM Jarvis\Models\Payments p WHERE p.aID = a.aID)',
                'disableFee' => '(SELECT SUM(p.sum) FROM Jarvis\Models\Payments p WHERE p.aID = a.aID)',
            ])
            ->addFrom(Gncc::class, 'g')
            ->innerJoin(Accounts::class, 'a');

This is how the query builder is looking right now. I'd appreciate any support, thanks!

0

There are 0 answers