0

I have a project that uses Propel 2 and there are two tables that I want to join on a certain field, but there is no foreign-key relationship there. I just want to match them up based on that value. Unfortunately I cannot get it to work, and Propel's documentation, thorough as it tries to be, still lacks a good reference. How can I do it?

What I have tried:

echo Table1Query::create()
        ->addJoin(Table1TableMap::COL_A, Table2TableMap::COL_B)
        ->where('Table2.C=?', 'asd')
        ->toString();

This fails at the where() part with System error Cannot determine the column to bind to the parameter in clause "Table2.C=?".

I know I can get the PDO connection and drop back into pure SQL, which would definitely be easier, but it kinda feels wrong when using an ORM (then again...).

Vilx-
  • 104,512
  • 87
  • 279
  • 422

1 Answers1

0

You need to do an explicit join type since you have not defined the relation in your schema, e.g.:

->addJoin(Table1TableMap::COL_A, Table2TableMap::COL_B, Criteria::JOIN_TYPE)
// INNER_JOIN, INNER_JOIN, etc
Qiniso
  • 2,587
  • 1
  • 24
  • 30