-1

I've been all over the web looking for answers on this. I hope someone here could help me with this.

I am trying to compose the query below using propel. Is possible?


SELECT * FROM table1
LEFT JOIN (table2, table3) ON (
     table1.id = table2.foreign_id 
     AND table2.foreign_id = table3.id
);

uji
  • 1,603
  • 3
  • 12
  • 12
  • 1
    Post some sample data and expected results for the sample data. I'm sure the SQL can be figured out. I do still have a concern that you shouldn't be mixing the `,` join notation with the ANSI-92 Join notation using the Join keyword; but maybe propel does something different. – xQbert Nov 15 '16 at 12:52
  • I'm note sure on your stand on the join notation because the two produces different results. I actually tried just using two separate joins instead of one but results were different since Im using a left join. It will work for inner join. But unfortunately that's not what Im looking for. Anyway, thank you for the reply, I have decided to just use custom sql and hack the s*** out of propel. – uji Nov 18 '16 at 07:48

2 Answers2

1

Have you tried something like this?

Table1Query::create()
    ->useTable2Query(null, Criteria::LEFT_JOIN)
    ->useTable3Query(null, Criteria::LEFT_JOIN)
    ->endUse()
    ->endUse()
    ->find();
chocochaos
  • 1,466
  • 10
  • 15
  • Yep tried it. Produces different sql query. I just read from propel that it is not possible. The only way right is custom sql. – uji Nov 18 '16 at 07:48
0

You can also create a view, then based on the view, create a model with readonly=true and skipSql=true attributes.

Qiniso
  • 2,587
  • 1
  • 24
  • 30